Test data loading in MS SQL

Sometimes, when I do stress testing of my app I would need massive data in order to test its performance. To perform a mass loading to your SQL database, you can run the script provided below.

Login MS SQL and go to File > New > Database Engine Query
image.png

Type in Use followed by the database name, then hit F5 to select the database of your choice.

USE <database name>;

Once the database has been selected, you can copy and paste the script below, then edit the following part(s) of the script: max value, table name, column(s) 1 to 4, finally value(s) 1 to 4.

DECLARE @MinValue INT;
DECLARE @MaxValue INT;
SET @MinValue = 1;
SET @MaxValue = <maximum number of your choice>;
WHILE @MinValue <= @MaxValue
    BEGIN
        INSERT INTO <table name>(column1, column2, column3, column4) 
        SELECT value1,value2,value3,value4
        SET @MinValue = @MinValue + 1
    END

Hit F5 to begin loading data to your table.

After loading the data, you can check the result under Messages

image.png