views:

46

answers:

2

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?

A: 

Do you mean a login name that has Login: Denied ? If so you can:

SELECT is_disabled from sys.server_principals WHERE name = @loginname
Alex K.
No.. For example if we entered wrong password for a specific MS SQL user more than 3-4 times account gets locked out. I want to check whether a specific account is locked out?
Santhosha
Ah; SELECT LOGINPROPERTY('loginname', 'IsLocked')
Alex K.
Thanks Alex.. This is what i am expecting.. Thanks a lot..
Santhosha
+1  A: 

Posting Answer on Behalf of Alex K.

SELECT LOGINPROPERTY('loginname', 'IsLocked')

Santhosha