Re: Link to table in another database

From: Jéjé (willgart_at_BBBhotmailAAA.com)
Date: 10/17/04


Date: Sun, 17 Oct 2004 19:01:09 -0400

creating a view which link 2 tables from 2 differents databases is very easy
in SQL

Because the syntax of a select statement is like this:
Select * from <Servername>.<Database>.<Catalog>.<Table>

So the answer to the question is :
select * from DB1.dbo.Table1 A inner join DB2.dbo.Table2 B
on A.Key = B.Key

This join your 2 tables.
And if your second database is on another server (or another instance), you
just have to add a linked server in the security information then:
select * from DB1.dbo.Table1 A inner join SERVERB.DB2.dbo.Table2 B
on A.Key = B.Key

(This remote server can be "any" database server like SQL Server, Oracle,
Access, DB2 ....)

"bill_morgan_3333" <bill_morgan_3333@discussions.microsoft.com> a écrit dans
le message de news: 316AE5B0-0681-4CDF-8E00-7E6E885724CF@microsoft.com...
> Friends,
>
> Our company is running two databases in one instance of SQL Server 2000
> (db_1 and db_2). QUESTION: From db_1, how do I link to a table in db_2 so
> that I can create a db_1 View that is a join between a table in db_1 and a
> table in db_2?
>
> For example, from an MS-Access ODBC link to our SQL Server, I can choose
> File / Get External Data / Link Tables to link to the two tables - one
> table
> in db_1 and the other table in db_2. Then I can create a query that joins
> the
> two linked tables.
>
> How can I accomplish this same join from within SQL Server?
>
> Thanks for your help ...
>
> Bill
>
>
>
>



Relevant Pages

  • Re: Create SQL cluster on 2003
    ... Since you are in a cluster configuration, ... Microsoft SQL Server MVP ... We only about about 20 databases - all ... Move Databases Between Computers That Are Running SQL Server ...
    (microsoft.public.sqlserver.clustering)
  • Re: Help!! Trying to migrate data from one SQL to another?!?
    ... I came up to the window on the DTS Wizard which has the option to ... I can defend myself on PL/SQL but I am not much of a SQL Server ... The application performs a replication between databases but due to ...
    (microsoft.public.sqlserver.dts)
  • Re: Side-by-side upgrade - moving master, msdb and model
    ... "In some cases, you may want to copy the system databases, including the ... from the source SQL Server 2000 instance to the SQL ... System Databases" in SQL Server 2005 Books Online to see how to do this" ... MVP - Windows Server - Clustering ...
    (microsoft.public.sqlserver.clustering)
  • Re: Side-by-side upgrade - moving master, msdb and model
    ... Microsoft SQL Server MVP ... MVP - Windows Server - Clustering ... from the source SQL Server 2000 instance to the SQL ... > 2005 instance before transferring user databases. ...
    (microsoft.public.sqlserver.clustering)
  • Re: Update MSDE2000 to SQL2000 on same server
    ... Yes you do an upgrade from MSDE to SQL 2000 Enterprise. ... a full database backup of all databases. ... Step 2 Click SQL Server 2000 Components. ...
    (microsoft.public.sqlserver.setup)

Loading