Insert multiple rows

How many times have we had to write multiple INSERT INTO statements? Well, SQL Server 2008 comes to the rescue. Its a small feature but still very useful.

You can now insert multiple rows into a table in a single statement.

INSERT INTO T1 (Col1,Col2,Col3)
VALUES

(‘Row1′, ‘Value’,‘Test’),
(‘Row2′, ‘Value’,‘Test’),
(‘Row3′, ‘Value’,‘Test’)

This inserts 3 rows into the T1 table. Certainly time-saving and makes those sometimes hefty insert scripts smaller.


3 Responses to “Insert multiple rows”

  1. James Says:

    I thought this would work too, but I get a syntax error on the ‘,’ after the first set of values. Any ideas? (Using SQLServer 2005).

  2. James Says:

    Oops sorry … I see that it’s a 2008 feature. Mea Culpa.

  3. Barry Says:

    Thank you for comment, yes unfortunately its a 2008 feature. You can download the CTP from here.

Leave a Reply