Inserting multiple rows to a database in a single call
I want to insert multiple rows to a database, but I don开发者_运维技巧't want to loop through and insert the rows that way.I am using data set.Data set brings a single table,which will contains some of record.I want to add multiple rows into database.I just want to avoid multiple calls in database.I am open for any suggestion or any example.
Please help me to solve the issue.Thanks in Advance.
With more recent versions (2008, 2008R2) of SQL Server you can add multiple rows in an insert statement:
insert into mytable (col1, col2)
values (1, 2),
(3, 4),
(5, 6)
you may insert through select. e.g.
insert into mytable1 (id, name, description)
select
id,
name,
description
from
mytable2
where
condition1=value1
精彩评论