Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bulk Insert multiple records and get identity for all using ADO.NET

I want to batch insert multiple records in sql server database using ADO.NET command/sqldataadapter and get identity value generated for all the rows in a single database trip.

What are my options?

like image 715
Muhammad Hasan Khan Avatar asked Apr 23 '10 09:04

Muhammad Hasan Khan


1 Answers

If you're using either, SQL server 2005 and 2008 add support for the OUTPUT clause, which enables you to return a result-set from an UPDATE/INSERT/DELETE statement.

like image 105
Ed Harper Avatar answered Oct 11 '22 16:10

Ed Harper