日期:2014-05-18 浏览次数:20489 次
declare @n int;set @n=10 select top(@n) misid,info_id from wl_misid
------解决方案--------------------
declare @n int
set @n=10
select top (@n) misid,info_id from wl_misid
------解决方案--------------------
--SQL2005 declare @dd int set @dd = 5 select top(@dd) misid,info_id from wl_misid --SQL2000 declare @dd int declare @str varchar(4000) set @dd = 5 set @str = 'select top ' + ltrim(@dd) + ' misid,info_id from wl_misid' exec(@str)
------解决方案--------------------
--如果是SQL SERVER 2000 declare @n int;set @n=10 declare @sql varchar(8000) set @sql='select top '+ltrim(@n)+' misid,info_id from wl_misid' exec(@sql)