Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Cwm
Starting Member
39 Posts |
Posted - 2008-12-09 : 12:24:12
|
| Hi Everyone,My question(s) is when i create a data table in C#, then do a sqlbulkcopy to copy it into the table, the question is if i was to put data from a couple different datatables and use the sqlbulkcopy how can i hav it set so it gets foreignkeyed?Here is some sample data, from datatable 1DataTable1ID OrderNumber Customer Product1 1234 Cust1 Prod12 2345 Cust2 Prod2datatable 2DataTable2ID DataTable1ID OrderNumber Carrier LoadTime34 1 1234 Carr1 9:0035 2 2345 Carr2 10:00Now when this gets sent to sql tables i will have an id that is autoincremented.What i want to know is how would i (after the copy) take the autoid from datatable 1 and put it to datatable 2 as a foreignkey?I have used a stored procedure before when adding large ammounts of data and having it split at a delimiter, with an if / else statement but could never get it to work properly because the data was at various lengths, and the if statements would fail.I hope i explained this clearly and that it isn't confusing the way i explained it.any samples would be appreciatedThanksChris |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-12-09 : 12:26:20
|
| Are you using sql 2005? if yes, have a look at OUTPUT operator |
 |
|
|
|
|
|