Click here to Skip to main content
15,891,529 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
I have to insert data into two table.First table pimary key values wil be used for second table.I have inserted data using SQLBulkcopy.How can i get inserted row from first table without commit the transction.End of the code only i can give commit for thes two tables.
Very urgent.
Posted
Updated 15-Oct-13 21:49pm
v2

1 solution

If you are using SQL 2005 or higher then you can use OUTPUT clause in your insert query. Using this you can access the magic tables(inserted,deleted). Please read this linkhttp://technet.microsoft.com/en-us/library/ms177564.aspx[^] for more info on using the output clause in your insert syntax
 
Share this answer
 
Comments
_dieQueeQ. 5-Jul-17 10:34am    
Dear Madhu Nair,
SqlBulkCopy is a .NET class that doesn't accept SQL query, only table name to insert to.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900