How To Change a Login Name in MS SQL Server?
Submitted by: AdministratorIf 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 ggl_Login WITH NAME = Dba_Login;
GO
-- View login names
SELECT name, sid, type, type_desc FROM sys.server_principals
WHERE type = 'S';
GO
<pre>name sid type type_desc
-------- ----------------------------------- ---- ---------
sa 0x01 S SQL_LOGIN
ggl_DBA 0x348AF32B3B58CB40B67A5F5B7086B96E S SQL_LOGIN
Dba_Login 0x5EB8701EAEBAA74F86FCF5BD8E37B8C5 S SQL_LOGIN</pre>
Submitted by: Administrator
-- Login with "sa"
-- Change login name
ALTER LOGIN ggl_Login WITH NAME = Dba_Login;
GO
-- View login names
SELECT name, sid, type, type_desc FROM sys.server_principals
WHERE type = 'S';
GO
<pre>name sid type type_desc
-------- ----------------------------------- ---- ---------
sa 0x01 S SQL_LOGIN
ggl_DBA 0x348AF32B3B58CB40B67A5F5B7086B96E S SQL_LOGIN
Dba_Login 0x5EB8701EAEBAA74F86FCF5BD8E37B8C5 S SQL_LOGIN</pre>
Submitted by: Administrator
Read Online MS SQL Server Job Interview Questions And Answers
Top MS SQL Server Questions
☺ | How to download Microsoft SQL Server 2005 Express Edition? |
☺ | What Are Binary String Data Types in MS SQL Server? |
☺ | What Happens If Strings Are Casted into Wrong Code Pages in MS SQL Server? |
☺ | Can You Roll Back the DDL Statement in a Trigger? |
☺ | How To Declare and Use Cursor Variables? |
Top Databases Programming Categories
☺ | RDBMS Interview Questions. |
☺ | SQL Interview Questions. |
☺ | SSRS Interview Questions. |
☺ | Database Administrator (DBA) Interview Questions. |
☺ | Sybase Interview Questions. |