dbTalk Databases Forums  

how to import data with relations

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss how to import data with relations in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
John5771
 
Posts: n/a

Default how to import data with relations - 11-14-2006 , 02:11 AM






I have 3 tables:

Import_accomodation:
- several attributes.....
- continentname
- regionname

Continent:
- ContinentId (PK)
- ContinentName

Country:
- CountryId (PK)
- ContinentId (FK, can be null)
- CountryName

The import_accomodation table is a flat table from which I want to transfer
data into the continent and country tables. Of course these are related. I
don't know which query to use for this. To fill continent I use:
insert into continent select continentname from import_accomodation where
continentname != '' and continentname not in (select name from continent)
But to fill country I don't know how to create a query to get the optional
relation.
Thanks a lot.
--
John

Reply With Quote
  #2  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: how to import data with relations - 11-14-2006 , 02:54 PM






Hello John5771,


Country you are looking to join Import_Accomodation to Continent where the
join attribute is ContinentName(LEFT OUTER JOIN). From this you will retrieve
the PK from ContinentID



Regards

Allan Mitchell
Konesans Ltd
T +44 7966 476 572
F +44 2071 008 479
http://www.konesans.com

Quote:
I have 3 tables:

Import_accomodation:
- several attributes.....
- continentname
- regionname
Continent:
- ContinentId (PK)
- ContinentName
Country:
- CountryId (PK)
- ContinentId (FK, can be null)
- CountryName
The import_accomodation table is a flat table from which I want to
transfer
data into the continent and country tables. Of course these are
related. I
don't know which query to use for this. To fill continent I use:
insert into continent select continentname from import_accomodation
where
continentname != '' and continentname not in (select name from
continent)
But to fill country I don't know how to create a query to get the
optional
relation.
Thanks a lot.



Reply With Quote
  #3  
Old   
John5771
 
Posts: n/a

Default Re: how to import data with relations - 11-15-2006 , 06:36 AM



Great, Allan, that solved my problem.

Thanks

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.