SQL Server中快速生成大量記錄的SQL指令碼

lawzjf發表於2008-01-20

下面指令碼快速生成1百萬條記錄的表:

set nocount on
use law
go

if object_id('dbo.nums') is not null
drop table dbo.nums
go

create table dbo.nums(n int not null primary key) on newFG
declare @max as int, @rc as int;
set @max=1000000
set @rc=1

insert into nums values(1)
while @rc*2<
begin
insert into dbo.nums select from dbo.nums
set @rc=@rc*2
end

insert into dbo.nums
select from dbo.nums where

select count(*) from dbo.nums

[@more@]

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/37724/viewspace-997822/,如需轉載,請註明出處,否則將追究法律責任。

相關文章