SQL2005:
create procedure Error_Get
(
@startindex int,
@pagesize int
)
as
begin
select top (@pagesize) * from Error where ER_ID Not In(select top(@pagesize*@startindex) ER_ID from Error order by ER_ID DESC) order by ER_ID DESC
end
go
SQL2000中则需要动态拼接,不支持变量
SQL2000:
create procedure Error_Get
(
@startindex int,
@pagesize int
)
as
begin
DECLARE @sql VARCHAR(8000)
SET @sql='select top ' +RTRIM(@pagesize)+ ' * from Error where ER_ID Not In(select top ' +RTRIM(@pagesize*@startindex)+ ' ER_ID from Error order by ER_ID DESC) order by ER_ID DESC'
EXEC(@sql)
end
go
- 本文标题: SQL2000存储过程分页问题,SQL2005中正常
- 文章分类:【SQLServer】
- 非特殊说明,本文版权归【胡同里的砖头】个人博客 所有,转载请注明出处.