天天看点

Server-Side 游标的使用

USE AdventureWorksDW2008R2

declare @P1 int  --游标号码

declare @P2 int

set @P2=8  --参数[传入参数](可能是游标类型)

declare @P3 int

set @P3=1  --参数[传入参数](可能是游标锁类型)

declare @P4 int  --返回行数

begin

exec sp_cursoropen @P1 output, 

 N'select * from DimCustomer', 

 @P2 output, 

 @P3 output, 

 @P4 output

exec sp_cursorfetch @P1, 16, 1, 100

--exec sp_cursorfetch @P1, 16, 第几条开始, 多少条数据

WAITFOR DELAY '00:00:05'

exec sp_cursorclose @P1

end

继续阅读