In this article, we will be discussing about how to rename logins in SQL Server.
A Scenario Where You Might Need to Rename a Login in SQL Server
When a Database Administrator creates Windows Logins in SQL Server, the format of these logins is:
[Domain or Server Name]\[Windows Username]
[Domain] can also be the local Server name if the user is a local Windows User.
In the case where the Server name changes and the Windows Login names remain the same in SQL Server then the login will not be usable. To this end, these login names have to be renamed.
How Rename Windows Logins in SQL Server
The syntax for renaming Windows Logins in SQL Server is:
ALTER LOGIN "[Domain or Server Name]\[Windows Username]" WITH NAME="[New Domain or New Server Name]\[Windows Username]"
*Note: You have to use the double quotes.
How to Rename SQL Logins in SQL Server
If you want to rename a SQL Server login (SQL Server Authentication) you can use one of the following syntaxes:
Syntax 1:
ALTER LOGIN "[SQL Server Login Name]" WITH NAME="[New SQL Server Login Name]";
Syntax 2:
ALTER LOGIN [SQL Server Login Name] WITH NAME=[New SQL Server Login Name]
As you may noticed from the above two examples, you can either select to use or not double quotes.
Strengthen your SQL Server Administration Skills – Enroll to our Online Course!
Check our online course on Udemy titled “Essential SQL Server Administration Tips” (special limited-time discount included in link).
Via the course, you will learn essential hands-on SQL Server Administration tips on SQL Server maintenance, security, performance, integration, error handling and more. Many live demonstrations and downloadable resources included!
Featured Online Courses:
- Boost SQL Server Database Performance with In-Memory OLTP
- Essential SQL Server Administration Tips
- SQL Server Fundamentals – SQL Database for Beginners
- Essential SQL Server Development Tips for SQL Developers
- The Philosophy and Fundamentals of Computer Programming
- .NET Programming for Beginners – Windows Forms with C#
- Introduction to SQL Server Machine Learning Services
- Introduction to Azure SQL Database for Beginners
- SQL Server 2019: What’s New – New and Enhanced Features
- Entity Framework: Getting Started – Complete Beginners Guide
- How to Import and Export Data in SQL Server Databases
- Learn How to Install and Start Using SQL Server in 30 Mins
- A Guide on How to Start and Monetize a Successful Blog
Read Also:
- SQL Server Installation and Setup Best Practices
- The TempDB System Database in SQL Server
- SQL Server 2016: TempDB Enhancements
- tempdb growth
- Introduction to SQL Server Machine Learning Services
- Essential SQL Server Administration Tips
- …more
Check our other related SQL Server Administration articles.
Subscribe to our newsletter and stay up to date!
Check out our latest software releases!
Check out our eBooks!
Rate this article:
Reference: SQLNetHub.com (https://www.sqlnethub.com)
© SQLNetHub
Artemakis Artemiou, a distinguished Senior Database and Software Architect, brings over 20 years of expertise to the IT industry. A Certified Database, Cloud, and AI professional, he earned the Microsoft Data Platform MVP title for nine consecutive years (2009-2018). As the founder of SQLNetHub and GnoelixiAI Hub, Artemakis is dedicated to sharing his knowledge and democratizing education on various fields such as: Databases, Cloud, AI, and Software Development. His commitment to simplicity and knowledge sharing defines his impactful presence in the tech community.