Friday, February 24, 2012

How to quickly create and populate a table to 1GB?

Hi All
How do i create a table which is as big as 1GB? I have tried some thing
below, but it it taking too long. Is there any quick way to do it? Here is my
sample i have tried and it's taking too long:
CREATE TABLE TableD
( X text)
GO
insert into tableD
values (replicate('h', 500000000))
GO
All i want is to have tableD to be 1GB for testing.
Thank you in advance.
Try this.
while (select count(*) from TableD)<5000
begin
insert into tableD
values (replicate('h', 500000000))
continue
end
TableD is 40,768KB
Divide 1,000,000 by 40,768 = 24
Now, DTS table out to txt file
declare @.counter int
select @.counter=0
while @.counter<24
begin
bulk insert TableD from 'C:\tableD.txt'
select @.counter=@.counter+1
continue
end
Mike K
"MittyKom" wrote:

> Hi All
> How do i create a table which is as big as 1GB? I have tried some thing
> below, but it it taking too long. Is there any quick way to do it? Here is my
> sample i have tried and it's taking too long:
> CREATE TABLE TableD
> ( X text)
> GO
> insert into tableD
> values (replicate('h', 500000000))
> GO
> All i want is to have tableD to be 1GB for testing.
> Thank you in advance.
>
|||How about something like the following. I was able to generate it in about
90 seconds on a slow workstation.
-- Set database to simple recovery mode
Create table #Numbers (
Number int)
declare @.x int
set @.x = 1
while @.x < 127000
Begin
insert #Numbers values (@.x)
set @.x = @.x + 1
End
select cast(' ' as char(4100)) as ColX
into TableD
from #Numbers
drop table #Numbers
"MittyKom" <MittyKom@.discussions.microsoft.com> wrote in message
news:78E92EEE-3245-4DB6-8870-8AD5B00A7CE3@.microsoft.com...
> Hi All
> How do i create a table which is as big as 1GB? I have tried some thing
> below, but it it taking too long. Is there any quick way to do it? Here is
> my
> sample i have tried and it's taking too long:
> CREATE TABLE TableD
> ( X text)
> GO
> insert into tableD
> values (replicate('h', 500000000))
> GO
> All i want is to have tableD to be 1GB for testing.
> Thank you in advance.
>

No comments:

Post a Comment