how to change server name in sql server

Solutions on MaxInterview for how to change server name in sql server by the best coders in the world

showing results for - "how to change server name in sql server"
Mila
07 Apr 2017
1-- If you find any mismatch, then you need to follow below steps:
2
3-- 1. Execute below to drop the current server name
4
5	EXEC sp_DROPSERVER 'oldservername'
6    
7-- 2. Execute below to add a new server name. Make sure local is specified.
8
9	EXEC sp_ADDSERVER 'newservername', 'local'
10
11-- 3. Restart SQL Services.
12
13-- 4. Verify the new name using:
14
15	SELECT @@SERVERNAME
16	SELECT * FROM sys.servers WHERE server_id = 0
17    
18-- I must point out that you should not perform rename if you are using:
19
20	-- 1. SQL Server is clustered.
21	-- 2. Using replication.
22	-- 3. Reporting Service is installed.