hi
i have 100 records in my datatable .Here i want to insert these records into SQL without looping .
thanks
insert into dbname.destination_table_name (dest_col1,dest_col2,dest_col3)
select source_col1,source_col2,source_col3
from dbname.source_table_name
where some_colname='some condition'
Hi,
You can try to use SqlBulkCopy Class in .NET.
SqlBulkCopy.WriteToServer Method (DataTable)
The above method copies all rows in the supplied DataTable to a destination table specified by the DestinationTableName property of the SqlBulkCopy object.
Also refer the following links.
Transferring Data Using SqlBulkCopy Class
Bulk Insert into SQL from C# App
hi
i have 100 records in my datatable .Here i want to insert these records into SQL without looping .
thanks
For You Have to Use
Bulk Query Concept Like Batch Processing....
string qry="";
For(int i=0;i<100;i++)
{
qry+="insert into tbl(id,name) values (1,'chirag')";
}
cmd.CommandType=qry;
cmd.executenonQuery();
100 record is not bulk for sql..
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.