Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 Database Design and Application Architecture
 Queries from Multiple Servers

Author  Topic 

vbGuru
Starting Member

1 Post

Posted - 2009-01-02 : 16:24:09
I think I can query from multiple databases on the same server by specifying the database name in the SELECT like

SELECT * FROM MyCustomerDb.Customers

But what if you wanted to join it with OldCustomersDb which is on a seperate server.... any way to do this in a Stored Procedure...

Never pour cream soda in your disk drive...

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2009-01-02 : 16:27:10
you have to create a linked server and use 4 part naming convention:
select * from LinkedServerName.DatbaseName.SchemaName.TableName


___________________________________________________________________________
Causing trouble since 1980
Blog: http://weblogs.sqlteam.com/mladenp
Speed up SSMS development: www.ssmstoolspack.com <- version 1.1 out!
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-01-03 : 07:13:37
or use OPENROWSET if its for an adhoc access

http://doc.ddart.net/mssql/sql70/oa-oz_5.htm
Go to Top of Page
   

- Advertisement -