sqlserver2000数据库中分页存储过程

create procedure PageSql(@pageindex int,@pagecount int,@tablename varchar(30),@keyname varchar(30))
as
declare @count int
declare @sqlstr varchar(1000)
select @count=(@pageindex-1)*@pagecount
set @sqlstr='select top '+cast(@pagecount as varchar)+

' * from '+@tablename+' where '+@keyname+

' not in (select top '+cast(@count as varchar)+

@keyname+' from '+@tablename+' order by '+@keyname+')

order by '+@keyname
exec (@sqlstr)

posted on 2011-01-19 17:00  神奇木马  阅读(384)  评论(0编辑  收藏  举报

导航