--利用游标更新数据
--声明游标
DECLARE CursorL21 CURSOR FOR SELECT GUID, RUNIT FROM L21
--打开游标
OPEN CursorL21;
--声明变量
declare @GUID CHAR(36)
DECLARE @UCODE NVARCHAR(11)
FETCH NEXT FROM CursorL21 into @GUID, @UCODE
WHILE(@@FETCH_STATUS=0)
BEGIN
PRINT @GUID
UPDATE L21 SET UCODE=@UCODE WHERE GUID=@GUID
fetch next from CursorL21 into @GUID, @UCODE
END
fetch next from CursorL21 into @GUID, @UCODE
print @GUID
CLOSE CursorL21
DEALLOCATE CursorL21