SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On



Linked Server - using results of one set of data for a (cursor?) Expand / Collapse
Author
Message
Posted Tuesday, May 31, 2005 10:34 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, May 31, 2005 1:51 PM
Points: 2, Visits: 1

Environment: SQL Server 2000, Linked server setup to an Oracle 9i DB.

I have a results set in SQL Server.    It has a column called pid.

pid has many more entries in the Oracle DB (also in a column called pid), spanning across many dates.  The one I have in SQL Server is just one of those dates.

I would like to retrieve ALL dates associated with each pid in Oracle and place them in a table in SQL Server.

Additional information (though may not be so relevant):  The original results set in SQL Server was taken from the Oracle DB.

Can anyone suggest a way to perform this?   I was thinking some complex use of cursor but wasn't sure if this was possible through the linked server mechanism.  Not sure why I added that note ... ANY solution is most welcome!

Sincere thanks in advance!

Post #186288
Posted Tuesday, May 31, 2005 12:33 PM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Tuesday, February 12, 2008 5:32 AM
Points: 1,758, Visits: 2

INSERT INTO tblPID

SELECT PID, PID_Date

  FROM LinkedServer.Database (Catalog?).Owner.Table

???





Good Hunting!

AJ Ahrens


webmaster@kritter.net
Post #186331
Posted Tuesday, May 31, 2005 1:22 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, May 31, 2005 1:51 PM
Points: 2, Visits: 1

Many thanks for the reply AJ   When I first read your reply, I wondered if I'd been a complete bonehead and not gone to the obvious solution

However, it turns out I may not have explained myself too well!

I would like to query only the pids (and therefore return all rows associated with each pid )associated from the original results set, not all the pids in the entire database/

Many thanks again!

Rob

Post #186345
Posted Tuesday, May 31, 2005 3:41 PM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Tuesday, February 12, 2008 5:32 AM
Points: 1,758, Visits: 2

If that is the case then

INSERT INTO tblPID

SELECT PID, PID_Date

  FROM LinkedServer.Database (Catalog?).Owner.Table L1

    INNER JOIN tblPID T1 ON L1.PID = T1.PID

NOTE:  This is only sample code and you will need to tweak it to NOT pull dates you already have





Good Hunting!

AJ Ahrens


webmaster@kritter.net
Post #186394
« Prev Topic | Next Topic »


Permissions Expand / Collapse