"ALTER LOGIN" - Changing a Login Name in SQL Server

Q

How To Change a Login Name in SQL Server?

✍: FYIcenter.com

A

If you want to change a login name, you can use the "ALTER LOGIN" statement as shown in this tutorial example:

-- Login with "sa"

-- Change login name
ALTER LOGIN Fyi_Login WITH NAME = Dba_Login;
GO

-- View login names
SELECT name, sid, type, type_desc FROM sys.server_principals
   WHERE type = 'S';
GO
name      sid                                 type type_desc
--------  ----------------------------------- ---- ---------
sa        0x01                                S    SQL_LOGIN
FYI_DBA   0x348AF32B3B58CB40B67A5F5B7086B96E  S    SQL_LOGIN
Dba_Login 0x5EB8701EAEBAA74F86FCF5BD8E37B8C5  S    SQL_LOGIN

 

Managing Security, Login and User in SQL Server

⇒⇒SQL Server Database Tutorials

2016-10-19, 413👍, 0💬