INSERT Multiple Records with a Single INSERT Statement in SQL Server

We have different ways to insert data in a table. The traditional approach is time consuming and boring because we have to repeat the same syntax again and again.
 
The following script helps to create the table.  
  1. Create table Mas_Employee(  
  2.    Id int primary key identity(1,1),  
  3.    Name varchar(50),  
  4.    Salary int ,  
  5.    DeptId int  
  6. )  
Traditional Method
 
Method 1 : Insert statement with column list.
  1. insert into Mas_Employee ( Name, Salary, DeptId )  values('Jaipal',18200,1);  
  2. insert  into Mas_Employee  ( Name, Salary, DeptId )  values ('Jayanth',14200,2);  
  3. insert  into Mas_Employee  ( Name, Salary, DeptId )  values ('Sreeshanth',12999,2);  
  4. insert  into Mas_Employee  ( Name, Salary, DeptId )  values ('Tejaswini',16800,1);   

Method 2 : Without using column list (into is optional).

  1. insert Mas_Employee  values ('Jaipal',18200,1);  
  2. insert Mas_Employee  values ('Jayanth',14200,2);  
  3. insert Mas_Employee  values ('Sreeshanth',12999,2);  
  4. insert Mas_Employee  values ('Tejaswini',16800,1);   

Method 3 : You can also use graphical representation.

Go to Object Explorer, then Databases, your Database. After that, go to Tables and open Mas_Employee table by clicking on it. Select 'Edit Top 10000 Rows' and insert your data
 
 
Single insert statement to Insert multiple records in table. 
  1. insert into Mas_Employee ( Name, Salary, DeptId )  values  
  2. ('Jaipal',18200,1),  
  3. ('Jayanth',14200,2),  
  4. ('Sreeshanth',12999,2),  
  5. ('Tejaswini',16800,1);  

I hope you enjoyed it. Please provide your valuable suggestions and feedback if you found this article helpful.

Ebook Download
View all
Learn
View all