declare @top int set @top = 5 select top @top * from tablename
是否可以?
或者对这样的逻辑有什么想法(我不想使用动态查询)?
是的,在 SQL Server 2005 中可以在top clause.
top
select top (@top) * from tablename