sqlserver 游标的简单示例
程序员文章站
2022-07-17 11:08:25
declare @id varchar(20) declare @name varchar(20) declare cur cursor for select substr...
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
上一篇: 微信小程序实现多选删除列表数据功能示例