Method 1:
When configuring data synchronization, the databases of the two synchronized machines must be connected by the default instance name. If your default instance has been deleted, you will be prompted when you create and release the instance:
"Microsoft SQL server cannot access these components because the replication components are not installed on this instance of SQL Server. For details, see SQL server ......"
Note that there is an additional prompt, which means that the default instance name and the current instance name are inconsistent. In fact, this is the main cause of the failure to copy. After solving this problem, you can copy it.
The reason is that after SQL Server is installed, the computer name is modified.
Solution: "replication requires an actual server name to connect to the server. The server alias, IP address, or any other backup name cannot be used for connection ."
I. First, check whether your default instance name is consistent with the current instance name. We will create a query in SqlServer2005 Management Studio.
SELECT @ SERVERNAME, SERVERPROPERTY ('servername ')
Two different results are displayed, indicating that the instance running first is not the default instance. You can change the running instance to the default instance in the following ways.
USE master
GO
-- Set two variables
DECLARE @ serverproperty_servername varchar (100 ),
@ Servername varchar (100)
-- Obtain information about the Windows NT Server and the instance associated with the specified SQL Server instance
SELECT @ serverproperty_servername = CONVERT (varchar (100), SERVERPROPERTY ('servername '))
-- Returns the name of the local Server running Microsoft SQL Server.
SELECT @ servername = CONVERT (varchar (100), @ SERVERNAME)
-- Display the obtained parameters
Select @ serverproperty_servername, @ servername
-- If @ serverproperty_servername is different from @ servername (because you changed the computer name), run the following
-- Delete the wrong server name
EXEC sp_dropserver @ server = @ servername
-- Add the correct server name
EXEC sp_addserver @ server = @ serverproperty_servername, @ local = 'local'
Restart the SQL statement and run SELECT @ SERVERNAME, SERVERPROPERTY ('servername ')
Method 2:
You need to configure a publishing and subscription, but always report: "SQL server replication requires an actual server name to connect to the server. You cannot connect to the server by alias, IP address, or any other backup name. Specify the actual server name "xxxx" (Replication Utlities ). "
After some analysis, we found that the machine name was modified after SQL server was installed. Run the following two statements:
Use master
Go
Select @ servername;
Select serverproperty ('servername ')
If the two results are inconsistent, the machine name is changed and the above error is reported during configuration replication.
-- To fix this problem
-- Execute the following statement and restart the SQL service.
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
Finally, don't forget to restart the service. After the service is started, run:
Use master
Go
Select @ servername;
Select serverproperty ('servername ')
Everything works, and replication works.