Thursday 28 May 2015

How to insert 1000 rows at a time

How to insert 1000 rows at a time

Create a table, suppose Status in which two columns first Id with Identity and another one is value.

CREATE TABLE Status
(
    ID INT IDENTITY(1,1),
   Value INT
)

Now Insert data into table Status

DECLARE @ID INT
SELECT @ID = 1
WHILE @ID>=1 AND @ID<=1000
BEGIN
  INSERT INTO Status VALUES(1)

END

Results:



No comments:

Post a Comment