游标例子
表结构如下:
tb1
   id int
   name varchar(20)

create  proc sp_youbiao   
as   
declare @id int  

--1 定义游标  
declare youbiaomc cursor for
        select id from TB1  

--2 打开游标
open youbiaomc  
 
--3 使用游标
fetch next from youbiaomc into @id  
 
while @@FETCH_STATUS=0   
begin  
   update TB1 set name=name+'test' where ID=@id  
   fetch next from youbiaomc into @id  
end  

--4 关闭游标  
close youbiaomc  
deallocate youbiaomc