首页 > 数据库技术 > 详细

sqlserver 游标的简单示例

时间:2016-01-21 00:11:07      阅读:165      评论:0      收藏:0      [点我收藏+]
Declare @Id varchar(20)
Declare @Name varchar(20)
Declare Cur Cursor For
select substring(id,0,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

sqlserver 游标的简单示例

原文:http://www.jb51.net/article/16028.htm

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!