In SQL 2008 some new row value constructors have been added, we are familiar with the INSERT statement which has been around for ages the ANSI way
INSERT INTO Table1 (column1 ,column2 ,... columnN) VALUES (value1,value2,....valueN)
Another way of inserting a single row of data is as follows
INSERT INTO Table1 SELECT value1,value2,....valueN
Similarly for multiple rows of data
INSERT INTO Table1 SELECT value1,value2,....valueN UNION SELECT value1,value2,....valueN UNION SELECT value1,value2,....valueN
Now the new ROW VALUE CONSTRUCTOR allows the following to add multiple rows of data
INSERT INTO Table1(column1 ,column2 ,... columnN) VALUES (value1 , value2 , ... valueN), (value1 , value2 , ... valueN), (value1 , value2 , ... valueN), (value1 , value2 , ... valueN), (value1 , value2 , ... valueN),
We normally use INSERT statements in stored procedures using parameters to the stored procedure, so the above row value constructor is not very useful , it seems to be use of a table valued parameter to insert multiple rows of data is a better option in SQL Server 2008
No comments:
Post a Comment