Can you create a linked server in SQL Server and then access it with an alias

You can create a linked server in SQL Server 2008 and then access it with an alias.

So, I create a linked server with "SalesServer", but I give it an alias of "Sales", so I can use it as follows:

SELECT * FROM Sales.DB1.dbo.DailySales 
+4
source share
1 answer

Yes ... the name of the linked server and the purpose of the linked server are two different parameters: sp_addlinkedserver . Avoid using the GUI, and this is obvious.

 EXEC sp_addlinkedserver @server = 'Sales', @srvproduct = 'SQL Server', @datasrc = 'SalesServer'; 

Note 1 to the table in the link actually mentions this

Edit: after commenting on another answer

sp_setnetname can be used to change the "datasrc" (ie, target) of the linked server. Why use a graphical interface?

+4
source

Source: https://habr.com/ru/post/1311752/


All Articles