游标示例2

SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
/*
select * from t_cpfl
*/

ALTER  proc P_InitDate
as
begin

 declare @id int
  declare @modelname varchar(50)
 declare @modeltype int
 declare curtmp scroll cursor
 for
 select id,modelname,modeltype from t_cpfl
 open curtmp
  fetch first from curtmp into @id,@modelname,@modeltype
 while (select @@fetch_status)=0
 begin
  update t_cpfl set clickhref='../ui_sys/xw/xwlist.aspx?ch_id='+rtrim(ltrim(str(@id)))+'&modelName='+@modelname
  where id = @id

  fetch next from curtmp  into @id,@modelname,@modeltype
  continue
 end
 close curtmp
 
end
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO

 

你可能感兴趣的:(游标)