Learning Curve…

Query to Insert large data in a sql table…

Posted on: December 2, 2011

Here is the Query to Insert large data in a sql table to test performance . This query could come in handy to test performance of application with  large data .

Just replace 1000000 in below query with your desired number of rows in a table.

DECLARE @intFlag INT
SET @intFlag = 1
WHILE (@intFlag <=1000000)
BEGIN

SET @intFlag = @intFlag + 1
INSERT INTO dbo.testTable
(id,Name)
VALUES
(newid(),’test’)
END
PRINT @intFlag
GO

Note :-after adding large data in your table , you may want to replace hard coded strings (like ‘test’ in above query) with some unique values to make data more readable , you can use below technique for the same :-

https://nikhatshahin.wordpress.com/2010/12/20/row_number-and-overorder-by/

Advertisements
Tags:

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Author

Learning days (Calendar)

December 2011
M T W T F S S
« Nov   Jan »
 1234
567891011
12131415161718
19202122232425
262728293031  

Knowledge Bank (Archives)

I am on Twitter

Blog Stats

  • 507,854 hits

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 43 other followers

%d bloggers like this: