Re: Link to table in another database
From: Jéjé (willgart_at_BBBhotmailAAA.com)
Date: 10/17/04
- Next message: Steve: "DTS Package: Source to Target Syntax?"
- Previous message: bill_morgan_3333: "Link SQL Server Tables"
- Next in thread: bill_morgan_3333: "Re: Link to table in another database"
- Reply: bill_morgan_3333: "Re: Link to table in another database"
- Messages sorted by: [ date ] [ thread ]
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
>
>
>
>
- Next message: Steve: "DTS Package: Source to Target Syntax?"
- Previous message: bill_morgan_3333: "Link SQL Server Tables"
- Next in thread: bill_morgan_3333: "Re: Link to table in another database"
- Reply: bill_morgan_3333: "Re: Link to table in another database"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|