In focus

How To Find Out Failed Login Attempt In SQL Server

In this article you will learn how to find the last login attempt with incorrect password in SQL Server.

Naresh Beniwal Apr 14, 2016


The LOGINPROPERTY () function is used to find the information about the login policy settings. This function is used to get the time of the last attempt to log in with an incorrect password.

The syntax of the LOGINPROPERTY () function is as follows:

Syntax:  LOGINPROPERTY ( 'login_name' , 'property_name' )

It takes the following arguments.
  • login_name - The name of an SQL Server login for which the login property status will be returned.

  • property_name - an expression that contains the property information to be returned for the login. Here, the property value is 'BadPasswordTime'.

  • Return Type: The Return type depends on the requested value. For the BadPasswordTime, the return type is datetime.
We can use the LOGINPROPERTY () function for logging attempts with an incorrect password in SQL Server,  shown as follows:

Here's a free e-book on SQL Server 2016: Microsoft SQL Server 2016: Mission-Critical Applications, Deeper Insights, Hyperscale Cloud.

function sql server