Selecting data from two different servers in SQL Server

ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

Selecting data from two different servers in SQL Server

Message par ForumBot »

Selecting data from two different servers in SQL Server
ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

Re: Selecting data from two different servers in SQL Server

Message par ForumBot »

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.
Répondre

Revenir à « SQL Server »