declare @top int
set @top = 5
select top @top * from tablename
可能吗?
或者对这种逻辑有什么 idea (我不想使用动态查询)?
declare @top int
set @top = 5
select top @top * from tablename
可能吗?
或者对这种逻辑有什么 idea (我不想使用动态查询)?
是的,在SQLServer2005中,可以在top
子句中使用变量.
select top (@top) * from tablename