1 SQL Server/3 Db's to connect to

C

cunger28

I have one SQL server with 3 db's that I need to connect to. I have 3 odbc's
set up for each database. I'd like to be able to perform pass-through
queries, but it looks like i can only do one odbc per pass through. The 3
db's have elements that need to link across the board.

I've read about adp's, but it looks like i can access one database at a time
that way too. I'd like to avoid linking a bunch of tables if possible.

Is there a way to have more than one database in a passthrough connection
string?

Thanks,
 
R

Rick Brandt

I have one SQL server with 3 db's that I need to connect to. I have 3
odbc's set up for each database. I'd like to be able to perform
pass-through queries, but it looks like i can only do one odbc per pass
through. The 3 db's have elements that need to link across the board.

I've read about adp's, but it looks like i can access one database at a
time that way too. I'd like to avoid linking a bunch of tables if
possible.

Is there a way to have more than one database in a passthrough
connection string?

Thanks,

If all three databases are on the same server you can do it all in one
SQL statement with one ODBC connection. You will have one default
database location established by the ODBC setup. Table references in
that database will be standard (only table name required). References
for tables in the other databases will be of the format...

DatabaseName.Owner.TableName
 
D

Danny J. Lesandrini

Chris:

I like ADPs and I use them a lot these days, but I think a Pass Through
will work for you. You just need to write the SQL correctly.

Let me give it a try here with a sample cross database query. The syntax
may not be perfect, but it will be something like the following. Assume I
have a table named tblErrorLog in 3 databases on a SQL Server, and I
want to query them all in one pass-through from Access. here's how ...

SELECT ErrNum, ErrDescr, ErrDateTime
FROM MyDatabase01.dbo.tblErrorLog

UNION SELECT ErrNum, ErrDescr, ErrDateTime
FROM MyDatabase02.dbo.tblErrorLog

UNION SELECT ErrNum, ErrDescr, ErrDateTime
FROM MyDatabase03.dbo.tblErrorLog

ORDER BY ErrDateTime DESC

Now, it doesn't really matter which ODBC connection I use. In fact, this
query could be executed on ANY SQL Server database because the
table paths are fully qualified.

Is this approximately what you were asking?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top