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
 SQL Server Development (2000)
 Need help in importing data

Author  Topic 

sujosh
Yak Posting Veteran

55 Posts

Posted - 2005-06-28 : 17:56:01
I need to retrieve records from Table A ( from Oracle) into a temp table and then insert into TAble B/ Table C (master detail into SQl Server DB).Then for each record inserted in Table C, I have to populate Table D,E and F. I am just oign to use three table to define what I am looking for

1) Select * from Table A
2) Insert this into a TEmp table
3) Loop through the temp table
4) For each record in Temp table
5) Create a record in Table B(SQl Server)
6) Get the PK from newly inserted row in Table B
7) Use that PK as the FK and insert into TAble C
8) Continue looping till end of row in the Temp table

Could someone please give me an idea as to how this SP should look like? Can this be done in DTS? Which option is better. I have written SP but not like this kind.

Thanks much!

derrickleggett
Pointy Haired Yak DBA

4184 Posts

Posted - 2005-06-28 : 22:30:29
Get rid of the loop.

Insert entire temp table into TableB
INNER JOIN temp table to TableB and insert resulting SELECT into TableC

If you want more help, read this:

http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

That will help you get answers faster on pretty much any forum out there.

MeanOldDBA
derrickleggett@hotmail.com

When life gives you a lemon, fire the DBA.
Go to Top of Page
   

- Advertisement -