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)
 Data Import

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2003-02-27 : 12:41:46
Jojee writes "Hi,

I have a coma delimited text file which I need to import to SQL server 7 on Windows 2000.

I could import the whole text file into a single table in SQL server. However that is not the results I needed.

In my text file I have repeating gropus of records.
For example the text file looks similar to this:
Company_Name Branch Contact_Person

<Line 1> Comp1 Branch1 Contact1
<Line 2> Comp1 Branch1 Contact2
. Comp1 Branch2 Contact1
. Comp1 Branch2 Contact2
. Comp1 Branch2 Contact3
<Line 6> Comp2 Branch1 Contact1
..... and so on.

In my SQL database I have 3 tables namely Company, Branch, and Contact. The degree of relationship between these three entities is that One Company can have more than one Branch and One Branch can have more than one Contact_Person. I need to import data so that I can distribute imported data to three different tables in SQL database. Also note that Branch being the child table of Company has company_id as foreign key in it. Similarly Contact_Person has a branch_id in it as foreign key.

How do I go ahead with the data import and at the same time honour the integrity constraints of my database?

Thanks in advance for the help!"

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2003-02-27 : 12:57:02
You should import the file into a flat table first and then disperse the data into your 3 tables using stored procedures. If you do it this way, would you need help on the stored procedures?

Go to Top of Page
   

- Advertisement -