Loading records to multiple table

Last Post 18 Aug 2007 02:50 PM by jung1975. 2 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
jung1975
New Member
New Member

--
18 Aug 2007 11:44 AM
I have a source table like below

Data_Staging:
Unique_id
Gender
Ethnicity
Race
MCP_key
Admission_Dt
Discharge_Date
Enrollment_key
Reason
Disability
Income
Employment


I need to load the data from this table to three different tables all have foreign key relationship

Registration Table:
Registration_key ( Indetity) -PK
Unique_id
Gender
Ethnicity
Race

Episode:
Episode_Key(Identity)- PK
Registration_key (FK)
MCP_key
Admission_Dt
Discharge_Date

Assessment Table:
Assessment_Key(Identity) – PK
Registraion_Key(FK)
Episode_Key(FK)
Enrollment_key
Reason
Disability
Income
Employment


How can I insert the records to three tables and keep the foreign key relationship?
I would like to use a set based insert statement ( no coursor)..

Can you show me some examples?

what about the foreign keys ( registration key and episode key) in Episode and assessment table?
these are the identity columns comes from registration and episode table.. how can i handle these keys during the child table insertion?


SwePeso
New Member
New Member

--
18 Aug 2007 01:46 PM
jung1975
New Member
New Member

--
18 Aug 2007 02:50 PM
Here is the output that I want to get

Data_Staging:
Unique_id Gender Ethnicity RACE MCP_Key Admission_DT Discharge_date Enrollment_key Reason Disbility Income Employment
100A1 M A 3 1010 01/4/1999 11/3/2006 163278 R Y 47389 UIN90




Here is the tables that I need to insert the records

Registration:
REgistration_key(Identity) unique_id GEnder Ethnicity Race
1000 100A1 M A 3

Episode
Episode_key(Identity) Registration_key(FK) ADmission_DT Discharge_Date
1 1000 01/4/1999 11/3/2006

Assessment:
Assessment_key ( identity) Registration_key(FK) Episode_key(FK) Enrollment_key Reasoin Disability Income Employment
10001 1000 1 163278 R Y 47389 UIN90



You are not authorized to post a reply.

Acceptable Use Policy