加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > MsSql教程 > 正文

SqlServer更改机器名后如何修改数据库的机器名

发布时间:2020-12-12 12:55:55 所属栏目:MsSql教程 来源:网络整理
导读:在安装好后服务器,并安装SQL Server软件后,如果需要修改主机名,除了修改注册表里面的东西外,还需要通过如下方式修改SQL Server认到的主机名 sp_dropserver 'HUANGQIN-4948B0' sp_addserver 'PUBLISHER','local' 本地的主机名也可以通过select * from sys
在安装好后服务器,并安装SQL Server软件后,如果需要修改主机名,除了修改注册表里面的东西外,还需要通过如下方式修改SQL Server认到的主机名

sp_dropserver 'HUANGQIN-4948B0'
sp_addserver 'PUBLISHER','local'
本地的主机名也可以通过select * from sys.servers 来查看。
更详细的信息

-- Run on SQL 2000 after server name change.??
-- To correct the sysservers system table. Note the following excerpt from online help about remote users and logins:

--??? If the computer has any remote logins,for example,if it is a?
--??? replication Publisher or Distributor,sp_dropserver may generate?
--??? an error similar to this:
--??? Server: Msg 15190,Level 16,State 1,Procedure sp_dropserver,Line 44
--??? There are still remote logins for the server 'SERVER1'.

--??? To resolve the error,you may need to drop remote logins for this server.?
--??? If replication is installed,disable replication on the server before?
--??? running the sp_dropserver stored procedure.

--?Side note:
--
--SQL Books Online is slightly incorrect with regard to sp_addserver when renaming a server. The correct syntax is
--? exec sp_addserver '<NEWSERVERNAME>','local'
--
--? If you do it the way it is specified in books online,the server is added with a new server id which is an identity field.?
--? If you try to replicate from (and possibly to) this server,replication setup will fail because it is looking for a server?
--? with an ID of 0 which won't be there. For some reason it uses this to determine something about the local computer?
--? and bombs.


exec sp_dropserver <old servername>
go
exec sp_addserver <new servername>','local'
go

-- To correct orginating server on JOBS:? If this isn't done,the jobs on?
-- the server can't be edited,SQL thinks they came from another server

update msdb.dbo.sysjobs?
set originating_server = '<new servername>'?
where originating_server = '<old servername>'

go

删除复制

http://msdn.microsoft.com/en-us/library/ms147921.aspx

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读