提问,这样的一个插入游标问题,谢谢各位大哥的帮忙
两个表
1:总表
ID CBM 。。。。
1 000001
2 000002
。 。
2:类别表
CBM Name
01 类1
02 类2
CBM(总表的第四,五个字段是类别表中的ID)
现在我有个这样的问题,在总表中增加了一个字段,想把类别表的Name,匹配的都插入到总表中,要用游标怎么做哈??
谢谢
begin tran
declare insertcompany cursor for
select substring(cbm,1,2)
from GDZCB
open insertcompany
commit tran
fetch next from insertcompany
WHILE @@FETCH_STATUS = 0
begin
insert into GDZCB (companyname) values('1')
end
close insertcompany
deallocate insertcompany
谢谢各位大哥了,谢谢