Selecting data from two different servers in SQL Server
Selecting data from two different servers in SQL Server
Selecting data from two different servers in SQL Server
Re: Selecting data from two different servers in SQL Server
What you are looking for are Linked Servers. You can get to them in SSMS from the following location in the tree of the Object Explorer:
`Server Objects-->Linked Servers`
or you can use [sp_addlinkedserver](http://msdn.microsoft.com/en-us/library/ms190479.aspx).
You only have to set up one. Once you have that, you can call a table on the other server like so:
```
select
*
from
LocalTable,
[OtherServerName].[OtherDB].[dbo].[OtherTable]
```
Note that the owner isn't always `dbo`, so make sure to replace it with whatever schema you use.
`Server Objects-->Linked Servers`
or you can use [sp_addlinkedserver](http://msdn.microsoft.com/en-us/library/ms190479.aspx).
You only have to set up one. Once you have that, you can call a table on the other server like so:
```
select
*
from
LocalTable,
[OtherServerName].[OtherDB].[dbo].[OtherTable]
```
Note that the owner isn't always `dbo`, so make sure to replace it with whatever schema you use.