能否实现SELECT TOP 10 FROM...的TOP后接实型变量参数?
请问怎么解决?
------解决方案--------------------
用动态sql实现
declare @sql varchar(1000)
declare @i int
set @i=10
set @sql= 'SELECT TOP '+rtrim(@i)+ ' * FROM sysobjects '
exec(@sql)
------解决方案--------------------
DECLARE @n INT
SET @n = 10
SET ROWCOUNT @n
SELECT * FROM tb
------解决方案--------------------
set rowcount 2
select * from tb
SET ROWCOUNT 0