欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

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