Thursday, April 10, 2008

New in SQL 2008:Inserting Multiple rows in One Insert..Value statement

With SQL Server 2008, Microsoft has introduced new feature from developer's perspective whereby executing One insert statement, you can insert multiple rows.

Consider below mentioned example with SQL 2005:

Declare @t1 TABLE(column1 INT)
INSERT @t1 VALUES(10)
INSERT @t1 VALUES(20)

Same example can be re-written with SQL 2008 as
Declare @t1 TABLE(column1 INT)
INSERT @t1 VALUES(10),(20)

No comments: