RE: Query tables across multiple databases with sql

From: Eric (Eric_at_discussions.microsoft.com)
Date: 08/25/04


Date: Wed, 25 Aug 2004 12:05:03 -0700

Chris, what you are talking about is 2 databases on 2 different servers? If
so, you need to add server B as a linked server on server A. You can do this
from Enterprise manager or Query analyser. From EQ manager go to the database
and look for "Security" and then "linked servers". From here, add server "B"
as a linked server. (see BOL for more detail). Once you have the likned
server "B" on server "A", you can then run query from server "A" to "B" with
the dot notation. You can also join a table on server a with B. Example from
server A:
SELECT *
FROM servername.databasename.dbo.tablename

good luck, Eric

> Hello:
>
> How do I write an sql statement to link tables in two databases and query
> them?
> For example:
>
> SELECT db1.table1.field1, db2.table1.field1 FROM Table1 INNER JOIN
> db1.table1.field1 ON db2.table1.field1 = db1.table1.field1
>
> This is for SQL Server 2000. Thank you.
>



Relevant Pages

  • Re: AS2005 ... what is wrong with it?
    ... What I have seen is that the dev server is *faster* than the prod server ... And does your dev server also have all 6 databases with all these roles? ... When I restore the "PROV" i got approx 20 sec. ... Starting from an empty data folder should show if this theory is true ...
    (microsoft.public.sqlserver.olap)
  • 2nd Post - Trouble Getting VS.Net 2003 WalkThrough working
    ... the server. ... MSDE either from the Setup or from the SQL2KDeskSP3 execute. ... it does look like some of the sample databases have been ... >> and they directed me to install MSDE and they attached a ConfigSamples ...
    (microsoft.public.sqlserver.msde)
  • RE: Server Explorer & Databases
    ... As for the visual studio's database server explorer, ... oracle, visual studio generally use the OLD DB provider which is for Oracle ... and support of most general funcctionalitis in latest version of Oracle. ... #Server Explorer for Oracle Databases ...
    (microsoft.public.vsnet.ide)
  • Re: 2nd Post - Trouble Getting VS.Net 2003 WalkThrough working
    ... The fact that the other databases exists phyiscally doesn´t mean that they ... can try to connect to SQL Server using OSL or a GUI. ... The Command OSQL ist for the commandline under DOS. ... > this MSDE either from the Setup or from the SQL2KDeskSP3 execute. ...
    (microsoft.public.sqlserver.msde)
  • Re: AS2005 ... what is wrong with it?
    ... I have 6 OLAP databases on the server. ... When I restore the "PROV" i got approx 20 sec. ...
    (microsoft.public.sqlserver.olap)