开发者

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

开发者 https://www.devze.com 2023-01-01 22:27 出处:网络
Can you create a linked server in SQL Server 2008 and then refer to it with an alias. So, I create a linked server to \"SalesServer\", but I give it the alias \"Sales\", so I can use it like thi开发者

Can you create a linked server in SQL Server 2008 and then refer to it with an alias.

So, I create a linked server to "SalesServer", but I give it the alias "Sales", so I can use it like thi开发者_如何学Pythons:

SELECT * FROM Sales.DB1.dbo.DailySales


Yes... the linked server name and the target of the linked server are 2 different parameters to sp_addlinkedserver. Avoid using the GUI and it's obvious.

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

Note 1 to the table in the link actually mentions this

Edit:, after comment to another answer

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

0

精彩评论

暂无评论...
验证码 换一张
取 消