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.
March 12, 2008 at 10:12 pm |
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).
March 12, 2008 at 10:13 pm |
Oops sorry … I see that it’s a 2008 feature. Mea Culpa.
March 13, 2008 at 10:58 am |
Thank you for comment, yes unfortunately its a 2008 feature. You can download the CTP from here.