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

在安装好后服务器,并安装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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值