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 2005 Forums
 SSIS and Import/Export (2005)
 SSIS to Populate Multiple Tables With Identity

Author  Topic 

jrp
Starting Member

4 Posts

Posted - 2009-06-30 : 10:34:12
Hi,
I would like SSIS to initially populate a table and once that table is populated, use its primary key as a foreign key to populate another table . E.g
BULK INSERT INTO TABLE A
NOW BULK INSERT INTO TABLE B BUT WE NEED TABLE A's Id to do this

Any Ideas?

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2009-06-30 : 13:32:55
If you are populating table A from a flat file, using a Data flow Task. Once table A is populated , use an SQL task to populate Table B from Table A.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-06-30 : 14:09:46
you can use lookup task to lookup first table and get pk value from it based on a matching field value
Go to Top of Page

jrp
Starting Member

4 Posts

Posted - 2009-07-01 : 04:36:00
Im not populating from a flat file but from another Database table, once Table A is populated how would I use an SQL task to populate B from A. I cannot simply have:

select Id
from TableA
WHERE NOT EXISTS (
a foreign key in TableB
)

Because sometimes there may be legitimate reasons why there will not be a TableA foreign key in TableB so the list from the query above will simply grow and grow (not ideal as the table row numbers are in the millions)
Go to Top of Page
   

- Advertisement -