Jerry Nixon on Windows: Disable/Rename a SQL 2005 login with tSQL

Jerry Nixon on Windows

Friday, March 14, 2008

Disable/Rename a SQL 2005 login with tSQL

Some new SQL 2005 functions in tSQL here. Note the cool ability to rename SA to something else!

/*
Disable a login
Rename a login
*/

ALTER LOGIN sa DISABLE;
Select * from sys.sql_logins

ALTER LOGIN sa WITH NAME = [sys-admin];
Select * from sys.sql_logins

ALTER LOGIN [sys-admin] WITH NAME = sa;
Select * from sys.sql_logins

ALTER LOGIN sa ENABLE;
Select * from sys.sql_logins