sqlserver 游标的简单示例

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

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

原文链接:https://www.f2er.com/mssql/64471.html

猜你在找的MsSQL相关文章