就是完成 select @max=max(ID) from (select top N from t)的功能 ============================================================================== 我不想有select top N from t操作的开销谢谢
调试欢乐多
GOselect @max=max(ID) from T
GO
GOdeclare @t table(id int)
insert @t select 1
union select 2
union select 3
union select 4
union select 5
union select 6select max(ID) from @t
GO /*-----------
4(所影响的行数为 1 行)*/
GOdeclare @t table(id int)
insert @t select 1
union select 2
union select 3
union select 4
union select 5
union select 6select max(ID) from @t
GO /*-----------
3(所影响的行数为 1 行)*/