How to List all Locked SQL Logins in SQL Server

To list all locked SQL logins in SQL Server, use the following query:

SELECT name, is_disabled, LOGINPROPERTY(name, N'isLocked') as is_locked
FROM sys.sql_logins
WHERE LOGINPROPERTY(name, N'isLocked') = 1
ORDER BY name;

locked_logins_list

To list all locked SQL logins in SQL Server, including the time when the login was locked out, use the following query:

SELECT name, is_disabled, LOGINPROPERTY(name, N'isLocked') as is_locked,
LOGINPROPERTY(name, N'LockoutTime') as LockoutTime
FROM sys.sql_logins
WHERE LOGINPROPERTY(name, N'isLocked') = 1
ORDER BY name;

locked_logins_list_lockout_time

To see how to unlock SQL login without changing the login password, read related blog post:

Unlock login without changing the password in SQL Server

If the post helped you, please share it:
Pin It

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">