欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

快速生成扩展表默认数据的脚本

程序员文章站 2023-10-27 12:02:58
declare @total int; declare @count int; set @count=0; SELECT @total=COUNT(1) FROM TB_JJ; create table #T ( rid int PRIMARY KEY, sys_guid NVARCHAR(40) ......
declare @total int;
declare @count int;
set @count=0;
SELECT @total=COUNT(1) FROM TB_JJ;

create table #T
(
  rid int PRIMARY KEY,
  sys_guid NVARCHAR(40)
);
INSERT INTO #T SELECT ROW_NUMBER() over (order by sys_guid) as rid,sys_guid FROM TB_JJ;
WHILE @count<@total BEGIN set @count=@count+10000; INSERT INTO TB_JJ_Info(sys_guid) SELECT sys_guid FROM #T where rid<=@count; DELETE FROM #T where rid<=@count; END DROP TABLE #T;