Is it possible to join tables from different databases? If so, what is the
format of the select statement? Both databases are on the same server.
TIA,

Signature
Terry
Cor Ligthert [MVP] - 06 Jul 2007 05:23 GMT
Terry,
A lot of answers on your question here,
http://groups.google.com/group/microsoft.public.dotnet.framework.adonet/search?g
roup=microsoft.public.dotnet.framework.adonet&q=join+different+databases
Cor,
> Is it possible to join tables from different databases? If so, what is
> the
> format of the select statement? Both databases are on the same server.
> TIA,
Mark S. Milley, MCSD (BinarySwitch) - 06 Jul 2007 16:08 GMT
Hi Terry -
The format is this:
[databasename].[object owner name (usally dbo)].[tablename]
use database1
select * from database2.dbo.mytable
Two things to note:
Cross-database queries (especially if you're combining results or
doing cross-database joins) are S L O W, especially on tables with a
massive amount of data. You may want to revisit your approach.
Make sure that whatever user you're connecting to the database as has
access to both databases.
Happy Coding,
-Mark