儲存過程中如何處理分頁

2022-02-07 07:40:44 字數 578 閱讀 9330

儲存過程中處理分頁的方法如下:

1。利用not in和select top分頁

select

top頁大小 

*from

t表where

(id 

notin

(select

top頁大小

*頁數 id

from

表order

byid))

order

byid

2。利用id大於多少和select top分頁

select

top頁大小 

*from

表where

(id 

>

(select

max(id)

from

(select

top頁大小

*頁數 id

from

表order

byid) 

ast))

order

byid

用這種方法時,先要判斷頁數,如果頁數,如果頁數為第一頁的,直接用 select top 頁大小 * from 表

在儲存過程中分頁

用儲存過程實現的分頁程式 鄒建 2003.09 引用請保留此資訊 呼叫示例 exec p show 地區資料 exec p show 地區資料 5,3,地區編號,地區名稱,助記碼 地區編號 if exists select from dbo.sysobjects where id object id...

Mysql儲存過程內中文亂碼,如何處理

mysql儲存過程內中文亂碼,如何處理 問題如下 在mysql自帶的test資料庫中建立如下測試表t3 create table t3 name varchar 33 default null engine innodb default charset utf8 name欄位的字符集也是utf8,再...

儲存過程中呼叫儲存過程

use northwind go 儲存過程1 功能 通過員工firstname inputempfirstname 獲得 員工id outid if exists select name from sysobjects where name p getempleeidbyname and type ...