sp_dropserver and sp_addserver not working

僤鯓⒐⒋嵵緔 提交于 2019-12-14 03:43:42

问题


I am using SQL Server Express 2008 R2 and I wanted to change the instance name from "machine name"\SQLEXPRESS2008R2 to just "machine name". I ran:

sp_dropserver 'old_name'

go

sp_addserver 'new_name', 'local'

go

Then restarted the SQL Service. Now when I look at

Select @@SERVERNAME --this is correct

But this isn't correct?

Select serverproperty('ServerName') --This still shows old name

So when I try to connect to my instance via SSMS I still have to connect using the old instance name isntead of the new on I just applied? What am I doing wrong? Why is the new name not taking?

Thanks,

S


回答1:


This is from books online:

Although the @@SERVERNAME function and the SERVERNAME property of SERVERPROPERTY function may return strings with similar formats, the information can be different. The SERVERNAME property automatically reports changes in the network name of the computer.

In contrast, @@SERVERNAME does not report such changes. @@SERVERNAME reports changes made to the local server name using the sp_addserver or sp_dropserver stored procedure.

And the first comment is correct. You'd have to reinstall SQL in order to change it to a default instance.

per BOL if you change the machine name with a named instances you have to use as follows:

sp_dropserver <'old_name\instancename'>
GO
sp_addserver <'new_name\instancename'>, local
GO



回答2:


Yes, rebooting the SQL server worked. now both names show up correctly.

SELECT @@SERVERNAME 

SELECT serverproperty('ServerName') 


来源:https://stackoverflow.com/questions/5956807/sp-dropserver-and-sp-addserver-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!