游标批量插入数据

mac2022-06-30  32

--开启游标遍历查询所需信息 declare @code varchar(50) declare my_test cursor for --定义游标 select DISTINCT Files[字段] from 【源表名】 --打开游标遍历循环条码 open my_test while @@FETCH_STATUS = 0 BEGIN fetch next from my_test into @code --查询 INSERT INTO 【目的表名】(Files1,Files2,Files3 ) VALUES(@code,'',getdate())end close my_test --释放游标 deallocate my_test

转载于:https://www.cnblogs.com/fengmingming/p/5868391.html

相关资源:利用游标多数据库查询单条数据方法
最新回复(0)