Hello,
I'm trying to figure out a consistent way to quickly execute a JOIN query between an ODBC data source and an excel range.
In this exemple, my ODBC source has a table with [material] and [EAN], I'm running and Excel macro that has about 5000 materials and I want to find their EAN codes. Doing it the easy way means running 5000 times the JOIN query in a loop. It's slow.
Through experience and experimentation I know that it's much faster to make an Access file, import the ODBC link, create a table and fill it with my 5000 materials and execute 1 JOIN query.
I want to have all of this happening in code, in the background, and leave nothing on the server.
My question is, is there a way to do this with only ADODB or DAO? Or will I need to create an Access application, new database, new tables, then kill the file on the server? I feel like I should be able to do something like this:
Obviously this is just a simplified view, but the idea is that. Can anyone advise me on this?
Actually creating a new Access project and building it in vba sounds clunky and unnecessary for a small query like such.
Thank you
I'm trying to figure out a consistent way to quickly execute a JOIN query between an ODBC data source and an excel range.
In this exemple, my ODBC source has a table with [material] and [EAN], I'm running and Excel macro that has about 5000 materials and I want to find their EAN codes. Doing it the easy way means running 5000 times the JOIN query in a loop. It's slow.
Through experience and experimentation I know that it's much faster to make an Access file, import the ODBC link, create a table and fill it with my 5000 materials and execute 1 JOIN query.
I want to have all of this happening in code, in the background, and leave nothing on the server.
My question is, is there a way to do this with only ADODB or DAO? Or will I need to create an Access application, new database, new tables, then kill the file on the server? I feel like I should be able to do something like this:
Code:
Dim db as ADODB.Connection
db.ConnectionString = "DSN=SQL MASTER"
db.Open
db.CreateTable "temptable"
For i = 1 to 5000
db.Execute("INSERT INTO temptable ...")
Next i
db.Execute("SELECT Material, EAN FROM Materials INNER JOIN temptable on material = material")
Obviously this is just a simplified view, but the idea is that. Can anyone advise me on this?
Actually creating a new Access project and building it in vba sounds clunky and unnecessary for a small query like such.
Thank you