SQLServer简单的游标示例
作者:韩明剑
时间:2021-04-10
浏览:35
点赞:0

概述:记录下游标简单的使用方式,便于以后用到在此代码基础上进行扩展。

代码:

DECLARE @pagename varchar(50)
SET @pagename = 'CL1'

DECLARE cursor_dwid cursor for
select ejbm from dwpage where pagename=@pagename
declare @dwid int
OPEN cursor_dwid
FETCH NEXT FROM cursor_dwid INTO @dwid
WHILE @@FETCH_STATUS = 0
BEGIN
	--功能代码
	FETCH NEXT FROM cursor_dwid INTO @dwid
END
CLOSE cursor_dwid
DEALLOCATE cursor_dwid

原创不易,转载请保留本站版权。