
August 31st, 2011, 06:06 PM
|
|
Contributing User
|
|
Join Date: Aug 2011
Posts: 46
  
Time spent in forums: 8 h 7 m 29 sec
Reputation Power: 3
|
|
|
Insert multiple rows in single query using TSQL
To insert multiple rows with the help of single query you can use following syntax:
Code:
Insert
Into daTable
( col1, col2, ... coln )
values
( '21', 9, ... 'oh' )
,( '22', 37, ... 'my' )
,( '23', 42, ... 'we' )
,( '24', 11, ... 'be' )
,( '25', 77, ... 'at' );
Code:
INSERT INTO Table1 (FirstColumn, SecondColumn)
SELECT 'First' ,1
UNION ALL
SELECT 'Second' ,2
UNION ALL
SELECT 'Third' ,3
UNION ALL
SELECT 'Fourth' ,4
UNION ALL
SELECT 'Fifth' ,5
|