how to change server name in sql server

-- If you find any mismatch, then you need to follow below steps:

-- 1. Execute below to drop the current server name

	EXEC sp_DROPSERVER 'oldservername'
    
-- 2. Execute below to add a new server name. Make sure local is specified.

	EXEC sp_ADDSERVER 'newservername', 'local'

-- 3. Restart SQL Services.

-- 4. Verify the new name using:

	SELECT @@SERVERNAME
	SELECT * FROM sys.servers WHERE server_id = 0
    
-- I must point out that you should not perform rename if you are using:

	-- 1. SQL Server is clustered.
	-- 2. Using replication.
	-- 3. Reporting Service is installed.

Are there any code examples left?
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source