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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query SQL Server and MS Access Database

Status
Not open for further replies.

Miked811

Programmer
Apr 17, 2005
61
0
0
CA
Hi Guys,

I want to query 2 databases. The first DB is SQL Server 2000 and the 2nd is MS Access.

I created this simple query in SQL Server but, it gives me an error saying "Invalid Object Name", where ODBC_TBL2 is an ODBC connection

Code:
SELECT TBL1.Field1
FROM TBL1 
INNER JOIN ODBC_TBL2.Field1 ON 
TBL1.Field1 = ODBC_TBL2.field1

I also get the same error message for:

Code:
SELECT TBL1.Field1
FROM TBL1 
INNER JOIN [C:\DB\ACS_TBL.MDB].TBL2 AS ODBC_TBL2 ON 
TBL1.Field1 = ODBC_TBL2.field1

I need this query in an ASP application I am creating. Links does not work in ASP.

I can query similar databases e.g. SQL Server vs SQL Server and MS Access vs. MS Access.

Thanks in advance for your help

Mike
 
Easiest way is to set up a linked server on SQL Server pointing to your Access database (this will have to be in a location accessible by the SQL Server service account, preferably in a folder somewhere on that server).

You can then treat it as an external database in a link as any other table, eg

linkeddb.tablename

If the ODBC connection is on your PC, remember that all SQL Server knows is what it has access to - any queries run via Access are executed by the SQL Server database engine and the results returned to your PC.
This is why the differing database type queries fail.

John
 
Hi John,

Thank you very much for your response. I will work on it now.

Link Server it is.

Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top