Blog Post

Normalize your Linked Server Names


This is a technique I’m sure many people are already using in their environments.  Instead of using the actual name of your SQL Server as the name of the linked server that you call, use a generic name.  For instance.  If you have a couple of servers named SQLSales02 and SQLMarketing01 that you want to set up linked servers for, consider using more generic names such as SalesServer and MarketingServer.

The main benefit we garner from this in our environment is that when we move back and forth between our Test/Development/Production environments, we don’t have to worry about changing the names of linked servers in the code.  We just point the linked server on development to the development sales server and the linked server on production points to the production linked server.  No code changes.  Another benefit this confers is that if you ever need to upgrade or replace SQLSales02 (and the name of the server changes) you don’t have to hunt down all the code pointed to it, you just change the linked server name. 

Enough selling it, here’s how you do it.



  The Generic name I’m using here is RNDSERVER

  The name of the actual server is SCDSQLDEV5

  Note that the Product name is SQL Native Client (manually typed)

  Don’t forget to set up your linked server users and configuration options on the next tabs, but those are all as normal.


Via T-SQL:

EXEC master.dbo.sp_addlinkedserver @server = N'RNDSERVER2',
@srvproduct=N'SQL Native Client', @provider=N'SQLNCLI', @datasrc=N'SCDSQLDEV5'


You rated this post out of 5. Change rating




You rated this post out of 5. Change rating