T-SQL游标使用模板
declare
@id int,
@id int,
@
--声明变量
declare Response cursor
for SELECT
--声明变量
declare Response cursor
for SELECT
FROM [InventionToolOldEffect].[dbo].[avibg] WHERE (是否效应 = 1)
ORDER BY 效应编号
ORDER BY 效应编号
--声明游标
open Response --打开游标
fetch next from Response
into
@id,
fetch next from Response
into
@id,
@
--将第一行游标内容存储在变量
while @@fetch_Status=0 --游标循环开始
begin
--将第一行游标内容存储在变量
while @@fetch_Status=0 --游标循环开始
begin
Print @id
-- 这里放游标内容
fetch next from Response into
@id,
fetch next from Response into
@id,
@
--将游标移动到下一行
end --游标循环结束
close Response --关闭游标
deallocate Response -- 释放游标
end --游标循环结束
close Response --关闭游标
deallocate Response -- 释放游标
浙公网安备 33010602011771号