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.

 All Forums
 SQL Server 2000 Forums
 Import/Export (DTS) and Replication (2000)
 DTS import CSV record to multiple tables

Author  Topic 

meethenry04
Starting Member

1 Post

Posted - 2004-02-24 : 06:10:59
Hi,

I am using DTS in SQL server2k

What is the best way to insert CSV records, where 1 record maps onto multiple tables with parent/child or PK/FK relationship.

eg.
CSV record
(ID, param1, param2, param3)

ParentTable(ID as PK)
Param1Table(ID as FK in ParentTable, param1)
Param2Table(ID as FK in ParentTable, param2)
Param3Table(ID as FK in ParentTable, param3)

Currently i am using multiple Transform Data tasks with ActiveX script. But it seems to work slow.

Thanks and regards,
Henry

nr
SQLTeam MVY

12543 Posts

Posted - 2004-02-24 : 06:24:35
Import into a staging table then work from there.

insert ParentTable select ID from staging
insert Param1Table select ID, param1 from staging
...

If the IDs are actually allocated in ParentTable not in the imported file then use blocks of records with unique fields to get the id.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -