首页 > 数据库 > SQL Server > 正文

sqlserver 游标的简单示例

2024-08-31 00:59:53
字体:
来源:转载
供稿:网友
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
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表