Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access 2 different databases from one SQL script

Status
Not open for further replies.

echogovadze

Programmer
Oct 19, 2011
2
GE
Hi,

I wander if i can write INSERT statment, which selects data from table that exists in database1 into table that exists in database2? If yes - what syntax should i use?

It is so simple in TSQL... but does not work in DB2

Thanks in advance!

Eka
 
Hi Eka,
I've not seen it done like this and have just tried and I receive an error telling me that the remote object is invalid.

From within db2system1 I can select data from a table in db2system2 by giving it the subsystem name e.g if the table in subsystem2 is called owner1.table1 I can run the SQL:

SELECT * FROM subsystem2.owner1.table1

from subsystem1 and get data back, but it seems as if trying to access both subsystems in one statement does not work. I'd be interested if anybody else knows a solution.

Marc
 
Thanks Marc,

Yes, SELECT * FROM subsystem2.owner1.table1 syntax does not work.. :(

I will post here if i get any answer from other forums.. :)


Eka
 
Suggest you look here and read about DRDA (Distributed Relational Database Architecture)

This is NOT complete info, but will give you an idea. You might also ask your database support if this is supported on your system.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top