How to insert multple rows/records using single/one INSERT command
In SQL 2000/2005 there is no direct feature for this. Below is the workaround.
INSERT INTO tblSuppServers (ServerName,Type)
(SELECT ‘LAB1′,’Dev’)
UNION
(SELECT ‘LAB2′,’Dev’)
UNION
(SELECT ‘LAB3′,’Dev’)
GO
For SQL 2008:
INSERT INTO MyTable (FirstCol, SecondCol)
VALUES (’First’,1),
(’Second’,2),
(’Third’,3),
(’Fourth’,4),
(’Fifth’,5)
Ref:
http://blog.sqlauthority.com/2008/07/02/sql-server-2008-insert-multiple-records-using-one-insert-statement-use-of-row-constructor/
http://www.daniweb.com/forums/thread34491.html