日期:2014-05-19  浏览次数:20722 次

怎么用一条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
------解决方案--------------------
那主要要看你要写入什么样的记录啦
不可一概而论