读书人

如何用一条Sql语句向表中插入10000条记

发布时间: 2012-01-11 22:28:46 作者: rapoo

怎么用一条Sql语句向表中插入10000条记录?不能用循环,怎么写?
如题。

[解决办法]

--创建含有10000行数据的临时表
select top 10000 identity(int,1,1) as id
into #t
from syscolumns a inner join syscolumns b on 1=1


select * from #t


drop table #t
[解决办法]
select top 10000 identity(int,1,1) as id
into #t
from syscolumns a inner join syscolumns b on 1=1
--------------------
可以了吧;
难道非要用
select top 10000 identity(int,1,1) as id into #t from syscolumns a inner join syscolumns b on 1=1

[解决办法]
insert into table1 select top 10000 * from table2
[解决办法]
select top 10000 identity(int,1,1) as id
into #t
from syscolumns a, syscolumns b
[解决办法]
那主要要看你要写入什么样的记录啦
不可一概而论

读书人网 >SQL Server

热点推荐