sqlserver裡乙個用於分頁取資料的儲存過程,希望大家多多指教
create
procedure
dbo.
gy_getpagerecord
@tbname
sysname
,@colkey
sysname
,@colselect
nvarchar
(1000),
@countperpage
int,
@pageindex
int,
@sortsql
nvarchar
(1000),
@wheresql
nvarchar
(1000)as
declare
@sql
nvarchar
(4000)
ifltrim
(rtrim
(@sortsql
))<>
''set
@sortsql
=' order by '
+@sortsql
ifltrim
(rtrim
(@wheresql
))=''
set@wheresql
='1=1'
else
set@wheresql
='('
+@wheresql
+')'
set@sql
='select top '
+cast
(@countperpage
asnvarchar
(10))
+' '
+@colselect
+' from '
+@tbname
+' where '
+@colkey
+' not in
(select top '
+cast
(@countperpage
*(@pageindex-1)
asnvarchar
(10))
+' '
+@colkey
+' from '
+@tbname
+' where '
+@wheresql
+@sortsql
+') and '
+@wheresql
+@sortsql
exec
(@sql)
set@sql
='select ceiling(cast(count(*) as decimal(18,10))/cast('
+cast
(@countperpage
asnvarchar
(10))+
' as decimal(18,10))) from '
+@tbname
+' where '
+@wheresql
exec
(@sql)
set@sql
='select count(*) from '
+@tbname
+' where '
+@wheresql
exec
(@sql)
go
乙個分頁儲存過程
page language c import namespace system.data import namespace system.data.sqlclient 訂單號 服務專案 預訂日期 操作人員 分配狀態 databinder.eval container.dataitem,offerid...
乙個分頁儲存過程
louje 分頁儲存過程 create procedure usp page pagesize int,頁大小 pageno int,頁號 tablename nvarchar 500 表名 keyword nvarchar 20 主鍵 fieldname nvarchar 2000 要顯示的欄位名...
乙個分頁儲存過程
create procedure sp page tb varchar 50 表名 col varchar 50 按該列來進行分頁 coltype int,col 列的型別,0 數字型別,1 字元型別,2 日期時間型別 orderby bit,排序,0 順序,1 倒序 collist varchar...