Join Tables From Different Databases In SQL Server 2008
Here I am going to explain how to join to a table in another database.
Here I am going to explain how to join to a table in another database. Join operator is used to fetch data from two or more than two table.
SQL Server can store tables in multiple databases. When you run a SELECT statement against one database, you can join a table in another database if you have appropriate permissions. To join tables from different database, you must prefix the table name in the another database with the name of that database.
For example, let's say you need to join the Student table in the person database with the Student1Details table in the master database. To do that you must specify table name along with their database name. Syntax of a table name that's qualified with a database name is:
Statement that is used to fetch data from Student1Details table in master database
Statement that is used to fetch data from Student table in person database
How do I join across database
FROM master.dbo.Student1Details S1
JOIN person.dbo.Student S2