Wednesday, May 28, 2014

How to change the Instance Name of SQL Server

SQL Server uses its own name, which could be different than the network server name, in order to know the name of your SQL server run the next command:

sp_helpserver
select @@servername


In order to change the name of the server you need to use the next commands:

sp_dropserver 'old_name'
go
sp_addserver 'new_name','local'
go

Don't get scare with the name of the commnad "DROP SERVER", it is just making reference to the SQL name.

After you ran the commands all you have to do is restart the SQL Server service, use the command @@servername to verify the new name of your server.

You cannot create a local SQL Server as a linked server

If you try to create a linked server to itself you will get the next error:


There is  a trick to do it, it is called loop back linked server.

In the Linked server textbox instead of providing the name of the SQL Server instance, type "." (only dot). This will indicate the linked server is a loopback linked server.



On the Security tab, choose "Be made using the login's current security context" select option.


Click the OK button to finish adding linked server to SQL Server which points to itself.

In Object Explorer window, you will see the new loopback SQL Server linked server with "." as the name.