declare @RegionCode varchar(32)
declare cursor1 cursor for
--定义游标cursor1
select RegionCode from dbo.ADM_REGIONS where RegionLevel = 3
--使用游标的对象(跟据需要填入select文)
open cursor1
--打开游标
fetch next from cursor1 into @RegionCode
--将游标向下移1行,获取的数据放入之前定义的变量@id,@name中
while @@fetch_status=0
--判断是否成功获取数据
begin
insert into [ObjectIdentity].[dbo].[ADM_COUNTYS](COUNTYId
fetch next from cursor1 into @RegionCode
end
close cursor1
--关闭游标
deallocate cursor1