Home >Database >Mysql Tutorial >SQL Server 复制需要有实际的服务器名称才能连接到服务器

SQL Server 复制需要有实际的服务器名称才能连接到服务器

WBOY
WBOYOriginal
2016-06-07 18:07:03983browse

今天在做sql Server 2005的实验的时候碰到的问题,问题描述很清楚,怀疑是我以前给计算机修改了名称而导致的.可以用select @@servername和select serverproperty ('servername')对照一下,两个的结果是否一样

今天在做sql Server 2005的实验的时候碰到的问题,问题描述很清楚,怀疑是我以前给计算机修改了名称而导致的.可以用select @@servername和select serverproperty ('servername')对照一下,两个的结果是否一样,不一样就会出现问题,以下给出解决的SQL脚本

代码如下:
if serverproperty('servername') @@servername
begin
declare @server sysname
set @server = @@servername
exec sp_dropserver @server = @server
set @server = cast(serverproperty('servername') as sysname)
exec sp_addserver @server = @server , @local = 'LOCAL'
end

执行之后 ,重新sql即可解决这个问题
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