How to change Sql Server name. A micro tips!

Hello friends,

Welcome back again!

Last time we have a long post about Disassembling the SQL Server parser so today we have a very short post...
Do you need to change the name of the instance of SQL Server?

Easy!

Let's step back

Some days ago i was connected with a customer.

I saw the name of the instance in the SSMS but if I execute a statement where the name of the server is explicited, like this:

 
select * from [instancename]. [database]. [dbo]. [Table] 

I get the Error:

Messaggio 7202, livello 11, stato 2, riga 10
Non è stato possibile trovare il server 'xxxxxx' in sys.servers. Verificare che sia stato specificato il nome corretto del server. Se necessario, eseguire la stored procedure sp_addlinkedserver per aggiungere il server a sys.servers.



Where is the problem?

If i execute the command 

 
Select * from sys.sysservers 

The servaname columns return a name that's not equal to the name displayed by the SSMS

 

So, how to solve?

As I sayd this is a very easy tips!
Just type into your SSMS and then execute this two commands:

 
EXEC SP_DROPSERVER 'OLDNAME'
EXEC SP_ADDSERVER 'NEWNAME',local

 

Finally RESTART Sql Server.


Thanks to all & Remember to think big and always share the knowledge!















Comments

  1. Thanks a lot for sharing this amazing knowledge with us. This site is fantastic. I always find great knowledge from it. Server Management Services

    ReplyDelete
  2. PPC campaign management is a critical and ongoing task that every Google Ads user must endure, regardless of account size. Therefore, investing in PPC campaign management software is something that any Google Ads user should consider.
    https://ppcexpo.com/blog/ppc-campaign-management-software

    ReplyDelete

Post a Comment

I Post più popolari

SQL Server, execution plan and the lazy spool (clearly explained)

SQL Server, datetime vs. datetime2

La clausola NOLOCK. Approfondiamo e facciamo chiarezza!