Tuesday, August 13, 2013

Row Constructor - Multiple Row Inserts Using Single SQL Query

Row constructor feature of SQL Server 2008 help with single query to insert multiple rows

Old Approach
 

insert into Customer(id,name,Age) values (100,'Ricardo',45)
insert into Customer(id,name,Age) values (101,'Michael',42)
insert into Customer(id,name,Age) values (102,'Antony',44)
insert into Customer(id,name,Age) values (103,'Zeus',43)




New Approach
 
 
insert into 
 Customer(id,name,Age)
 values
   (100,'Ricardo',45),
   (101,'Michael',42),
   (102,'Antony',46),
   (101,'Zeus',43)


1 comment:

Unknown said...

Thanks
it was very helpful