Wednesday, March 28, 2012

Linking 2 Databases

How do i get a query in 1 database to fetch results from a table in another database?
I am using MSSQL 2005I hope ur question is like this

You have 2 database DB1 and DB2. You want to select Tab2 in DB2 while you are executing the query in DB1.

The query would be like this

Select *
From DB2.dbo.Tab2

the general syntax would be

Select <column1>,<column2>......
from <database_name>.dbo.<table_name>

No comments:

Post a Comment