create proc xp_pager
@tablename varchar(20),
@pagesize int,
@pageindex int,
@primarykey varchar(20),
@strwhere varchar(500)
asdeclare @sqlstr varchar(2000)
if(@strwhere!='')
begin
set @sqlstr='select top '+cast(@pagesize as varchar(10))
+' * from '+@tablename
+' where '+@primarykey
+' not in (select top '+cast((@pagesize*(@pageindex-1)) as varchar(10))+' '+@primarykey
+' from '+@tablename
+' where '+@strwhere+' order by '+@primarykey
+') and '+@strwhere+' order by '+@primarykey
endelse
begin
set @sqlstr='select top '+cast(@pagesize as varchar(10))
+' * from '+@tablename
+' where '+@primarykey
+' not in (select top '+cast((@pagesize*(@pageindex-1)) as varchar(10))+' '+@primarykey
+' from '+@tablename
+' order by '+@primarykey
+') order by '+@primarykey
endexec(@sqlstr)
資料海量分頁儲存過程(2)
use forepress go 物件 storedprocedure dbo usp downloaddata 指令碼日期 02 28 2008 19 06 40 set ansi nulls on goset quoted identifier on go 分頁讀取井資料儲存過程 alter p...
資料海量分頁儲存過程(3)
declare strsql varchar 6000 主語句 declare strtmp varchar 1000 臨時變數 declare strorder varchar 500 排序型別 if ordertype 0 begin set strtmp select min set stro...
mysql 通用儲存過程分頁 海量資料分頁
老話題了,不多說了看 吧 測試表create table if not exists test id int 11 not null auto increment,sort int 11 title varchar 50 primary key id engine innodb default ch...