Home  >  Article  >  Database  >  修改电脑、伺服器名称后,SQL Server 的修正作业--补遗篇

修改电脑、伺服器名称后,SQL Server 的修正作业--补遗篇

WBOY
WBOYOriginal
2016-06-07 17:46:571141browse

笔者这边重新整理:重新命名 SQL Server 作业系统的电脑名称后之修正作业。
今整理如下:
(1)修正 @@servername

请使用以下的程式码,直接执行修正即可,无须填写任何资料。执行完成后,系统会自动关机,您仅需重新启动 SQL Server 即可。

DECLARE @sn sysname,@sno sysname;
SELECT @sn=cast(serverproperty('servername') as sysname),@sno=@@SERVERNAME;
IF @sno IS NULL
 BEGIN
  EXEC sp_addserver @server=@sn,@local = 'local';
  SELECT N'Finish the server name to revise, and has already stopped serving, please restart the server';
  SELECT N'完成伺服器名


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn