March 1, 2011 at 12:31 pm
I have two tables one a parent and one a child.
I have a web service that I am receiving data from a remote computer that gives me a list of status
location 1, getdate(), T,T,T,F,T,T,F,F (parent data)
and then details for the parent. in the child table.
parentID, '','','','error 5','','','error 6','error8'
How do insert both sets of data with a FK to the parent tables unique id
March 1, 2011 at 12:59 pm
if the parent table uses an identity field for the primary key, you can assign a variable to the identity inserted with the scope_identity() function.
--------------------------------------------------------------------------
When you realize you've dug yourself into a hole....Step 1...stop digging.
March 1, 2011 at 1:26 pm
Insert the parent data, use an "output" clause to get the necessary data from that in order to create the child data, and then use that to insert the child data.
I would need to see the format of the actual data to give more specifics, but the key thing is to take a look at the "output" clause that was added in SQL 2005 and how you can use that.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply