Xpode.com        Click here to Print this article.

Insert Multiple records with single Insert statement in sql server

insert into persons
(
p_id, First_Name, Last_Name, Address, city
)
values
(
'2', 'Shyam', 'Kumar', 'Address2', 'city2'
)


insert into persons
(
p_id, First_Name, Last_Name, Address, city
)
values
(
'3', 'ghanShyam', 'Kumar', 'Address3', 'city3'
)

It will enter 2 records in database. The same functionality may be achieved by Single Insert Statement.

insert into persons
(
p_id, First_Name, Last_Name, Address, city
)
select '2', 'Shyam', 'Kumar', 'Address2', 'city2'
unian all
select '3', 'ghanShyam', 'Kumar', 'Address3', 'city3'



http://
http://

Contributed by:
Rohit kakria
I am software developer

Resourse address on xpode.com
http://www.xpode.com/Print.aspx?Articleid=494

Click here to go on website