Skip to main content

In SQL Server 2005 and earlier versions, you had to execute 3 different INSERT statements in order to insert 3 rows into a table.

- Advertisement -

For example:

insert into Students(Name, Phone) values('Student #1', '123456')
 
insert into Students(Name, Phone) values('Student #2', '234567')
 
insert into Students(Name, Phone) values('Student #3', '345678')

Luckily, in SQL Server 2008 you can insert multiple records using a single INSERT statement. The previous queries could be summarized as follows:

insert into Students (Name, Phone)
values
  ('Student #1', '123456'), 
  ('Student #2', '234567'), 
  ('Student #3', '345678')

Limitation

This approach is limited to 1000 entries only. If you try to insert more than 1000 records you'll get error:

"The number of row value expressions in the INSERT statement exceeds the maximum allowed number of 1000 row values."

- Advertisement -
- Advertisement -