sqlserver 游标的简单示例

Declare @Id varchar(20) Declare @Name varchar(20) Declare Cur Cursor For select
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生成连续数字根据指定的数字操作

SQLServer中JSON文档型数据的查询问题如何解决

SQLServer备份数据库的完整步骤

在SQLServer中如何使用TryCatch处理异常的示例详解

SQLServer序列SEQUENCE用法介绍