C#技术百科
问问你的心你有没有信心 做事情要专一坚定,执着

declare @GID varchar(36)
declare @Column_ID varchar(36)
declare @Column_Name varchar(36)
declare @Parent_ID    varchar(36)
declare @Fathers_ID varchar(36)
declare @Three    varchar(36)
declare @Main varchar(360)
DECLARE @cmd sysname, @var sysname
declare @int int
declare democursor cursor

for
select Gid,three,main,Column_ID,Parent_ID,fathers_ID,Column_Name from (select rtrim(ltrim(replace(substring(right(cast([主营产品或服务] as varchar(1200)),len(cast([主营产品或服务] as varchar(1200)))- charindex(';',cast([主营产品或服务] as varchar(1200)))),charindex(';',right(cast([主营产品或服务] as varchar(1200)),len(cast([主营产品或服务] as varchar(1200)))- charindex(';',cast([主营产品或服务] as varchar(1200)))))+1,charindex(';',right(cast([主营产品或服务] as varchar(1200)),len(cast([主营产品或服务] as varchar(1200)))- charindex(';',cast([主营产品或服务] as varchar(1200)))),charindex(';',right(cast([主营产品或服务] as varchar(1200)),len(cast([主营产品或服务] as varchar(1200)))- charindex(';',cast([主营产品或服务] as varchar(1200))))))),';',''))) three,[主营产品或服务] main,Gid from companys where Fid is null) tab ,V_sort bbb where tab.three like '%'+bbb.Column_Name+'%' and bbb.Column_Name<>'其他'
print '--start'
open democursor
fetch next from democursor into @GID,@Three,@Main,@Column_ID,@Parent_ID,@Fathers_ID,@Column_Name

while @@FETCH_STATUS=0

begin

print 'update companys set Fid='+isnull(@Fathers_ID,'')+',Sid='+isnull(@Parent_ID,'')+',Tid='+isnull(@Column_ID,'')+' where Gid='+isnull(@GID,'0')+'--'+isnull(@Main,'')+isnull(@Column_Name,'')
--insert into regulation(newone,newtwo,newthree,oldone,oldtwo) values(@Column_ID,@Parent_ID,@Fathers_ID,@bs_id,@ss_id)

fetch next from democursor into @GID,@Three,@Main,@Column_ID,@Parent_ID,@Fathers_ID,@Column_Name

end
print '--end'
close democursor
deallocate   democursor

 

 

一个到数据的游标代码

posted on 2008-08-09 15:42  王德田  阅读(160)  评论(0编辑  收藏  举报