sqlserver 游标的简单示例
时间:2021-04-27 09:08:39|栏目:MsSql|点击: 次
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
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
上一篇:SQL截取字符串函数分享
栏 目:MsSql
下一篇:SQL Server误设置max server memory的处理方法
本文标题:sqlserver 游标的简单示例
本文地址:http://www.codeinn.net/misctech/109777.html