SQL 存储过程 NOT IN 的问题。
ALTER PROCEDURE sArticle @currentPage int ASdeclare @sql1 varchar(250)declare @sql2 varchar(250) set @sql1 ='select top 20 ID,Topic,Author,AddTime,ViewNum from Article order by ID desc'set @sql2 ='select top 20 ID,Topic,Author,AddTime,ViewNum from Article where ID not in ([color=#FF0000]select top (@currentPage-1)*20 ID from Article order by ID desc[/color]) order by ID desc'if (@currentPage=1) execute (@sql1)else execute (@sql2)
ALTER PROCEDURE sArticle @currentPage int ASdeclare @sql1 nvarchar(250)declare @sql2 nvarchar(250) set @sql1 ='select top 20 ID,Topic,Author,AddTime,ViewNum from Article order by ID desc'set @sql2 ='select top 20 ID,Topic,Author,AddTime,ViewNum from Article where ID not in (select top ((@currentPage-1)*20) ID from Article order by ID desc) order by ID desc'if (@currentPage=1) execute (@sql1)else exec sp_executesql @sql2,N'@currentPage int',@currentPage