dbTalk Databases Forums  

from 1 file to 2 tables with identity

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


Discuss from 1 file to 2 tables with identity in the microsoft.public.sqlserver.dts forum.



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

Default from 1 file to 2 tables with identity - 12-02-2003 , 02:12 PM






Howdy all. Im wondering if theres a way to do the
following:


Source .txt file;
col1
col2
col3
col4

Destination table1;
IDCol Identity column
col1
col2

Destination table2;
IdCol value from table1
col3
col4

The problem is getting the ID value for table2
I can use either a Global Variable or a Lookup Value but
the problem is that it will only pass back one value. How
do I insert one row to table1, get the Id, insert 1 row
into table2 including that Id... and so on?


TIA, Chris

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

Default Re: from 1 file to 2 tables with identity - 12-02-2003 , 02:50 PM






How about

Insert the col1 and col2 into table1 in one datapump

For table2 load then you compare the col1 and col2 values in table1 with
those in the text file and load the appropraite identity value from a
lookup.

--
--

Allan Mitchell (Microsoft SQL Server MVP)
MCSE,MCDBA
www.SQLDTS.com
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org

"chris" <anonymous (AT) discussions (DOT) microsoft.com> wrote

Quote:
Howdy all. Im wondering if theres a way to do the
following:


Source .txt file;
col1
col2
col3
col4

Destination table1;
IDCol Identity column
col1
col2

Destination table2;
IdCol value from table1
col3
col4

The problem is getting the ID value for table2
I can use either a Global Variable or a Lookup Value but
the problem is that it will only pass back one value. How
do I insert one row to table1, get the Id, insert 1 row
into table2 including that Id... and so on?


TIA, Chris



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

Default Re: from 1 file to 2 tables with identity - 12-02-2003 , 04:17 PM



Quote:
Insert the col1 and col2 into table1 in one datapump

Whats a datapump?

Quote:
For table2 load then you compare the col1 and col2 values
in table1 with
those in the text file and load the appropraite identity
value from a
lookup.

Now Im really lost. The identity value doesnt exist in the
text file so I cant compare the tables to it. Am I missing
something?

Quote:
-----Original Message-----
How about

Insert the col1 and col2 into table1 in one datapump

For table2 load then you compare the col1 and col2 values
in table1 with
those in the text file and load the appropraite identity
value from a
lookup.

--
--

Allan Mitchell (Microsoft SQL Server MVP)
MCSE,MCDBA
www.SQLDTS.com
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org

"chris" <anonymous (AT) discussions (DOT) microsoft.com> wrote in
message
news:03f301c3b910$a2cfab80$a101280a (AT) phx (DOT) gbl...
Howdy all. Im wondering if theres a way to do the
following:


Source .txt file;
col1
col2
col3
col4

Destination table1;
IDCol Identity column
col1
col2

Destination table2;
IdCol value from table1
col3
col4

The problem is getting the ID value for table2
I can use either a Global Variable or a Lookup Value but
the problem is that it will only pass back one value.
How
do I insert one row to table1, get the Id, insert 1 row
into table2 including that Id... and so on?


TIA, Chris


.


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

Default Re: from 1 file to 2 tables with identity - 12-03-2003 , 12:15 AM



Ahhhhhhhhh

OK

A Datapump is the act of moving data from source to destination. Sorry for
the terminology.

1. Pump Col1 and Col2 into Table1. This will give you your identity values
in table1 yes?
2. Now pump col3 and col4 into Table2. To get the identity value from
table1 you can perform a lookup passing in col1 and col2 and returning the
ID column

Have you read this article

How to Use Lookups in DTS
(http://www.sqldts.com/default.aspx?277)

--
--

Allan Mitchell (Microsoft SQL Server MVP)
MCSE,MCDBA
www.SQLDTS.com
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org

"chris" <anonymous (AT) discussions (DOT) microsoft.com> wrote

Quote:
Insert the col1 and col2 into table1 in one datapump

Whats a datapump?

For table2 load then you compare the col1 and col2 values
in table1 with
those in the text file and load the appropraite identity
value from a
lookup.


Now Im really lost. The identity value doesnt exist in the
text file so I cant compare the tables to it. Am I missing
something?

-----Original Message-----
How about

Insert the col1 and col2 into table1 in one datapump

For table2 load then you compare the col1 and col2 values
in table1 with
those in the text file and load the appropraite identity
value from a
lookup.

--
--

Allan Mitchell (Microsoft SQL Server MVP)
MCSE,MCDBA
www.SQLDTS.com
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org

"chris" <anonymous (AT) discussions (DOT) microsoft.com> wrote in
message
news:03f301c3b910$a2cfab80$a101280a (AT) phx (DOT) gbl...
Howdy all. Im wondering if theres a way to do the
following:


Source .txt file;
col1
col2
col3
col4

Destination table1;
IDCol Identity column
col1
col2

Destination table2;
IdCol value from table1
col3
col4

The problem is getting the ID value for table2
I can use either a Global Variable or a Lookup Value but
the problem is that it will only pass back one value.
How
do I insert one row to table1, get the Id, insert 1 row
into table2 including that Id... and so on?


TIA, Chris


.




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.