Wednesday, August 06, 2008

SQL Server 2008 New Feature - Insert statement supports multiple record

With SQL Server 2008, we have got an interesting enhancement in Insert statement.

Originally from previous releases of SQL Server until SQL Server 2005, an INSERT statement was supposed to accept set of values for one row/record at a time.

INSERT INTO Customers (Name,Qty,Price)
Values('A',2,12)

INSERT INTO Customers (Name,Qty,Price)
Values('B',3,24)


But with SQL Sever 2008, we can insert multiple rows/records at a time just separated by comma as a delimiter:

INSERT INTO Customers (Name,Qty,Price)
Values('A',2,12),('B',3,24)


This will help the developers to save their time while inserting data.

No comments:

Post a Comment