关于查询语句用top +变量的问题

来源:互联网 发布:淘宝客服可爱的开场语 编辑:程序博客网 时间:2024/06/05 13:25
declare @i int
set @i=1
select top (@i) * from test
这样的小脚本,目的是取出一个表中的 前几行,参数一般是从外部传入的。
注意 直接使用select top @i * from test 是不可以的。(@i) 就可以解决问题