This is a question that has stumped me for the longest time. I really hope
someone out there has done this before, or can help.
I need to execute a cross database query in my C++ program. We have
SQLServer 2000 and a db connection set up from our computer. My query looks
something like this:
"DELETE FROM files WHERE SUBSTRING(name, (LEN(name) - CHARINDEX('\',
REVERSE(name)) +2), 16) IN (SELECT filename FROM customers..jobs WHERE status
The ‘..’ in the above query is supposed to switch databases… this whole
query runs fine in AQT and if executed from our web servers. However, I am
unsure how to make my C++ program execute the query.
CRecordset rs ( &m_db );
m_db.OpenEx ( "DSN=myDatabase1;UID=xxxxx;PWD=xxxxxx\0");
m_db.ExecuteSQL ( sql_string ); // where sql_String is the query above
Basically, I am trying to cross a table from myDatabase1 with a table from
the customers database. But I don't see a way that m_db can connect to 2
different databases at once.
Does anyone here know how to do this? Is there a way to associate m_db with 2 different databases at once so the join can be done?
Thank you all.