34,576
社区成员
发帖
与我相关
我的任务
分享
declare @sql as nvarchar(4000)
declare @count as int
set @count=100 --200,300,400
set @sql=' declare @tb table(id int,[name] nvarchar(10))'+ --把这里改成你的临时表@tb 的定义
' insert @tb select * from table '+ --把这里改成你的insert 语句
' select top '+left(@count)+' from @T'
exec(@sql)
create table #tb
(
id int
)
declare @i int;
set @i=0
while @i<1000
begin
insert into #tb values(@i);
set @i=@i+1;
end
select top(100)* from #tb
create proc aaa
@count int
as
begin
select top(@count)* from #tb
end
exec aaa 100
--试试这个是你要的结果不是