帮我优化一下这个存储过程
declare @tempsql varchar(8000)
begin
set @tempsql='select top' +str(@temp_ipage)+ ' * from table1 where id=1 and id not in (select top '+str(@temp_spage)+' id from table1 where id=1) order by id desc'
execute(@tempsql)
end
如果@temp_spage的数量特别多,效率就会低,而且@tempsql的长度8000也不够用。。。有什么办法实现类似功能???