Wednesday, August 24, 2011

Data Population Query

DECLARE @I INT --Declare a varialbe for holding starting value
SELECT @I = 1 -- Defining starting value

 WHILE @I < 1000 -- Checking condition for the limit
BEGIN

INSERT INTO TABLE1 -- Inserting table declaration
           (COLUMN1,
           COLUMN2,
           COLUMN3,
           GET_DATE
           .
           .......
           )
                SELECT
                100 + @I, NULL,NULL,GETDATE(),....... -- value passed for the table
               
SELECT @I = @I + 1 -- Incrementing the value for the varialble to check for while condition

END

No comments:

Post a Comment