tags:

views:

48

answers:

2

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 this:

SELECT * FROM Sales.DB1.dbo.DailySales
+1  A: 

Have you tried doing this?

Joe Swan
Essential! this way, when you change the linked server, you don't have to rewrite all your stored procs. Thanks for pointing the trick.
iDevlop
A: 

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?

gbn