Hi, main query (database 1) would have an inner part with a subquery (database 2).
Is it possible to run this in 1 sequence and spit out one result set into new Listobject,
alternatively Recordset?
Do you have such example please ?
Hi, main query (database 1) would have an inner part with a subquery (database 2).
Is it possible to run this in 1 sequence and spit out one result set into new Listobject,
alternatively Recordset?
Do you have such example please ?
Last edited by pulsar777; 08-09-2016 at 08:19 AM.
Not able to understand properly.. Could you please clarify a bit?
Cheers!
Deep Dave
A simple concept would look like this:
So idea is to create new ListObject table where external source would present the SQL which has 2 connections .Please Login or Register to view this content.
Last edited by pulsar777; 08-10-2016 at 01:17 PM.
Is the Sub Query to a different Server or a different Database?
Besides, (Though never tried it before) If such a query executes properly on SQL, if should work without any problems in Excel too.
They're 2 different servers. A Company's software can execute that where (visually) it first connects into once source (asks for credentials), makes a pull and then asks to log into next source to complete the retrieval.
As a user, I don't see the details of that procedure. I assume in terms of excel VBA, one Sub would establish a connection to subquery, retrieve results into a memory (Recordset) and that would be used as a parameter,
to join with tables in main query. But from lack of my VBA-SQL knowledge, I seem not to put it into practice. Or is there a simpler way ?
Last edited by pulsar777; 08-10-2016 at 03:13 PM.
I just tried to JOIN a Recordset (subquery) with a table in main query, but I get Type Mismatch as Recordset.Source of main query expects SQL as a string.
That part was like:
Please Login or Register to view this content.
Last edited by pulsar777; 08-11-2016 at 08:41 AM.
You might have to Initialise 2 connections 1 after another, 1 will have the values stored in the recordset, then the connection string will initialise the 2nd connection and use the recordset values in the 2nd query.
I will try to generate some code and post it in a while
Hi NeedForExcel,
I established 2 connections, got the first Recordset from the subquery. That Recordset now should behave like a second table I'd like to JOIN with tables in main query. Can't figure out how to reference that rs in SQL string though. So I removed JOIN keyword and just did instead:
No error this time, but I got very strange result setPlease Login or Register to view this content.
Well, I don't think that is possible. I mean you might not be able to "Join" a SQL Table with a RS.That Recordset now should behave like a second table
Considering my limited knowledge with SQL, I might be wrong on the above statement though.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks