当前位置: 代码迷 >> Sql Server >> 请教如何取出表中的不定前几行
  详细解决方案

请教如何取出表中的不定前几行

热度:47   发布时间:2016-04-27 17:28:16.0
请问怎么取出表中的不定前几行?
select   top   n   from   table
n能不能用变量控制呢?

------解决方案--------------------

declare @i int
set @i=3

exec(select top '+rtrim(@i)+ ' * from t)
  相关解决方案