May 31, 2005 at 10:34 am
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!
May 31, 2005 at 12:33 pm
INSERT INTO tblPID
SELECT PID, PID_Date
FROM LinkedServer.Database (Catalog?).Owner.Table
???
Good Hunting!
AJ Ahrens
webmaster@kritter.net
May 31, 2005 at 1:22 pm
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
May 31, 2005 at 3:41 pm
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
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply