数据库
首页 > 数据库> > SQL server 游标用法

SQL server 游标用法

作者:互联网

declare @EmpCode varchar(50), @EmpName varchar(50), @EmpAddress varchar(200);
declare curEmployee cursor for
select empcode, empname, empaddress from tblCursor
open curEmployee

fetch curEmployee into @EmpCode, @EmpName, @EmpAddress
while @@FETCH_STATUS = 0
begin
select @EmpCode, @EmpName, @EmpAddress,@@FETCH_STATUS

fetch curEmployee into @EmpCode, @EmpName, @EmpAddress

end

-- 关闭游标

close curEmployee

-- 删除游标

deallocate curEmployee

标签:curEmployee,EmpCode,EmpName,游标,server,EmpAddress,SQL,varchar
来源: https://www.cnblogs.com/flms/p/12377957.html