![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
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 |
#3
| |||
| |||
|
|
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 (AT) discussions (DOT) microsoft.com> a écrit dans le message de news: 316AE5B0-0681-4CDF-8E00-7E6E885724CF...soft (DOT) 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 |
![]() |
| Thread Tools | |
| Display Modes | |
| |