Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2012 Forums
 Other SQL Server 2012 Topics
 Linked Servers/Alias

Author  Topic 

Dhudson29
Starting Member

23 Posts

Posted - 2014-11-03 : 11:31:33
I am moving an SQL instance to another server. However there are linked servers. There is one particular linked server who's name is used in much code and applications that I need to point to. Can I create an alias using the same name? This instance I'll call "oldinstance" will be shut down, but I need to keep that name so that everywhere that name is referenced in the new instance, all the applications still work. Please advise, because I al really lost on this one!

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2014-11-03 : 12:23:34
Yes linked servers can reference aliases. The alias must be created on the database server itself. I always add it to the 32-bit and 64-bit sections in the registry in case 32-bit software, such as SSMS, is used. Of course this is only needed on 64-bit machines.

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

Dhudson29
Starting Member

23 Posts

Posted - 2014-11-03 : 12:52:28
What's the proper way to reference a linked server name in a query that contains a backslash? (i.e, ABCD\Server)
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2014-11-03 : 13:46:25
quote:
Originally posted by Dhudson29

What's the proper way to reference a linked server name in a query that contains a backslash? (i.e, ABCD\Server)



Just put square brackets around it.

select * from [server1\instance1].db1.dbo.t1 where...

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

jeffw8713
Aged Yak Warrior

819 Posts

Posted - 2014-11-04 : 14:11:55
You can also create the linked server with a different name - it doesn't have to have the same name as the server.

To avoid these kinds of issues in the future, you should consider creating synonyms for all objects accessed through the linked server. This way, you can easily change the linked server name - then just update the synonyms. All code would then use the synonyms and won't have to be modified.
Go to Top of Page
   

- Advertisement -