卢象升传翻译:在SQL Server中如何向一张表中插数据,急!!!

来源:百度文库 编辑:神马品牌网 时间:2024/04/28 08:40:25
在SQL Server中如何向一张表中立即插一万条记录
脚本怎么写啊

打开SQL查询分析器,复制脚本,按F5
use pubs;
create table 你的表(c1 int primary key,c2 datetime default getdate() )
go

declare @num int;
set @num=1;
while @num<=10000
begin
insert into 你的表(c1) values(@num);
set @num=@num+1;
end

insert into select top 10000 * from [table]

可以写成脚本插入

写一个程序连接数据库循环10000次插入一万条记录不就行了

将表2的前一万笔资料一起插入表1 , 范例如下 :

insert into 表1 select top 10000 * from 表2