比如存在表a1 包括2列 id,apply_type,将数据逐行插入B
declare @myid int
decalre @app nvarchar(50)
declare mycursor cursor for
select id,apply_type from a1 >>声明游标
open mycursor >>打开游标
fetch next from mycursor into @myid,@app
while @@fetch_status=0
begin
要对数据怎么处理可自己添加
insert into b values(@myid,@app) >>这是做插入操作
fetch next from mycursor into @yhid,@app >>继续读a1下条数据
end
close mycursor >>关闭游标
deallocate mycursor >>释放游标