Populate Large Tables with Random Data in SQL Server

use db1

CREATE Table tblBook

(

   Id int identity primary key,

   Author_name nvarchar(50),

   country nvarchar(50)

)

 

 

use db1

Declare @Id int

Set @Id = 1

 

While @Id <= 2000000

Begin

   Insert Into tblBook values ('Author - ' + CAST(@Id as nvarchar(10)),

              'Country - ' + CAST(@Id as nvarchar(10)) + ' name')

   Print @Id

   Set @Id = @Id + 1

End

 

 

This will insert 2000000 rows in table tblBook

Comments