设为首页 加入收藏

TOP

T_SQL利用游标遍历表记录,更新每条记录ID值
2014-11-23 22:20:19 来源: 作者: 【 】 浏览:9
Tags:T_SQL 利用 游标遍 记录 更新

利用游标遍历表,更新表记录

declare @Id bigint

declare @count int

declare @eventIDvarchar(50)

set @Id = 4294967297

declare my_Cursorcursor local for

select EventCodefrom eventRule

open my_Cursor

while @@FETCH_STATUS= 0

begin

fetch next from my_Cursor into @eventID

update EventRule set ID = @Id where EventCode= @eventID

set @Id = @Id + 1

end

close my_Cursor

deallocate my_Cursor

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇SQLSERVER添加约束限制序列 下一篇sql分组取每组的前n条或每组的n%..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: