I want to unlock one account in SQL Server. Before unlocking I have to check whether that account is locked or not.
I want to unlock only if the account is locked.
Is there any SQL query or stored procedure to get the "Locked" status of SQL user?
I want to unlock one account in SQL Server. Before unlocking I have to check whether that account is locked or not.
I want to unlock only if the account is locked.
Is there any SQL query or stored procedure to get the "Locked" status of SQL user?
Do you mean a login name that has Login: Denied ? If so you can:
SELECT is_disabled from sys.server_principals WHERE name = @loginname
Posting Answer on Behalf of Alex K.
SELECT LOGINPROPERTY('loginname', 'IsLocked')