sqlserver 游标的简单示例

前端之家收集整理的这篇文章主要介绍了sqlserver 游标的简单示例前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

感兴趣的小伙伴,下面一起跟随编程之家 jb51.cc的小编两巴掌来看看吧!

Declare @Id varchar(20)
Declare @Name varchar(20)
Declare Cur Cursor For
select substring(id,7) as id,name from temp1
Open Cur
Fetch next From Cur Into @Id,@Name
While @@fetch_status=0
Begin
Update temp Set [c3]=@Name where [id] like @Id+'%'
Fetch Next From Cur Into @Id,@Name
End
Close Cur
Deallocate Cur

猜你在找的MsSQL相关文章