473,386 Members | 1,621 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Imprting to a parent and child tables from two csv files using dts package

1
Hi,
I want to import data to a parent and child table from two different csv files.
Csv file for the parent table have got the primary key(integer) field and child have the forien key . My problem is that the last primary key value in the parent table may not match with the new ones . So i need to create ID's on import . IS there any way to relate these two tables in this manner using dts package.

Thanks
Anuja
Feb 15 '07 #1
1 1859
almaz
168 Expert 100+
You cannot "automagically" link the tables, as DTS inserts data from different sources using different tasks. So you'll have to:
1. Insert both source tables into temporary tables with parent temp table containing additional identity field (let's name it new_id). (using 2 tasks)
2. In a single SQL task:
  1. Open transaction.
  2. Find the largest identity value in the target parent table (Let's name it @MaxID).
  3. Insert data from parent temp table into target parent table, using new_id + @MaxID as a primary key (you'll have to execute SET IDENTITY_INSERT ... ON first).
  4. Insert into target child table data from temp data table, joined on temp parent table, using resolved new_id + @MaxID as a reference to parent table.
  5. Close transaction.
Feb 16 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Walt Borders | last post by:
Hi, My problem: Merging two datasets deletes parent elements, preserves all children. I've created two dataSets. Each use the same schema, parent-child nested tables. The first dataSet is...
3
by: maricel | last post by:
Is there a way to list (using db2 command or catalogs) to list hierarchy of table parent & child relationship: 1) A list that shows which table should be deleted first,second,third... 2) A list...
13
by: Stuart McGraw | last post by:
I haven't been able to figure this out and would appreciate some help... I have two tables, both with autonumber primary keys, and linked in a conventional master-child relationship. I've...
1
by: Earl Teigrob | last post by:
I did a ton of searching to try and find a simple solution to this issue and finally wrote my own, which I am sharing with everyone. In my searching, I did find a very complete and robust solution at...
4
by: Frank | last post by:
Hello, I have a dataset with 2 tables and a relation (parent - child). I linked that ds to a datagrid. Shows everything fine (very little coding for such functionality!). But.. in the child row I...
3
by: reachsamdurai | last post by:
Is it possible to determine the list of child/parent tables for a particular table from any system catalog tables? Using the syscat.tables I'm able to retrieve the no of dependent parent/child...
8
by: Rick | last post by:
VS 2005 I' m setting up a parent/child datagridviews in a form. I am doing a lot of this by hand coding in order to get the feel of things. I want a change in the parent table to trigger a...
3
by: creative1 | last post by:
Here is how you create a complex data report that involves parent and child commands and you can update information at runtime. Its pretty straight forward to work with simple queries; however,...
1
by: Bob Johnson | last post by:
..NET 3.5, Windows Forms app: My objective is to display parent/child data in two ComboBox controls, such that when a parent item is selected in one combo box, associated child items appear in the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.