Obtaining a "locked" account status in SQL Server

I want to unlock one account in SQL Server. Before unlocking, I need to check whether this 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 status "Locked" for an SQL user?

+5
source share
2 answers

Submitting a response on behalf of Alex K.

SELECT LOGINPROPERTY ('loginname', 'IsLocked')

+6
source

Do you mean the login that Login: Denied has? If so, you can:

SELECT is_disabled from sys.server_principals WHERE name = @loginname
+4
source

All Articles