Click here to Skip to main content
15,895,011 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
I am using sqlbulkcopy to insert chunks of data into sql server database.is there any way to get the primarykey value for recntly inserted data so that i can insert into log table?
Posted
Comments
Bala Selvanayagam 14-Oct-11 17:18pm    
Have you thought about using triggers ?
[no name] 18-Oct-11 1:00am    
If they put trigger then it will slow down the process and it is of no use to do bulk copy

1 solution

Add a new column in the table i.e. sessionid
after that you can select the ids by the sessionid.

ie. Bulk Insert with var sessionID = new GUID();
SQL Query Select ID from TableName where SessionID = sessionID;

I think this will help you.
 
Share this answer
 

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