THIS TOPIC APPLIES TO: SQL Server Azure SQL Database Azure SQL Data Warehouse Parallel Data Warehouse
Returns information about login policy settings.
Is the name of a SQL Server login for which login property status will be returned.
Is an expression that contains the property information to be returned for the login. propertyname can be one of the following values.
Returns the number of consecutive attempts to log in with an incorrect password.
Returns the time of the last attempt to log in with an incorrect password.
Returns the number of days until the password expires.
Returns the SQL Server login default database as stored in metadata or master if no database is specified. Returns NULL for non-SQL Server provisioned users (for example, Windows authenticated users).
Returns the login default language as stored in metadata. Returns NULL for non-SQL Server provisioned users, for example, Windows authenticated users.
Returns the number of passwords tracked for the login, using the password-policy enforcement mechanism. 0 if the password policy is not enforced. Resuming password policy enforcement restarts at 1.
Indicates whether the login has expired.
Indicates whether the login is locked.
Indicates whether the login must change its password the next time it connects.
Returns the date when the SQL Server login was locked out because it had exceeded the permitted number of failed login attempts.
Returns the hash of the password.
Returns the date when the current password was set.
Returns the algorithm used to hash the password.
Data type depends on requested value.
IsLocked, IsExpired, and IsMustChange are of type int.
1 if the login is in the specified state.
0 if the login is not in the specified state.
BadPasswordCount and HistoryLength are of type int.
BadPasswordTime, LockoutTime, PasswordLastSetTime are of type datetime.
PasswordHash is of type varbinary.
NULL if the login is not a valid SQL Server login.
DaysUntilExpiration is of type int.
0 if the login is expired or if it will expire on the day when queried.
-1 if the local security policy in Windows never expires the password.
NULL if the CHECK_POLICY or CHECK_EXPIRATION is OFF for a login, or if the operating system does not support the password policy.
PasswordHashAlgorithm is of type int.
0 if a SQL7.0 hash
1 if a SHA-1 hash
2 if a SHA-2 hash
NULL if the login is not a valid SQL Server login
This built-in function returns information about the password policy settings of a SQL Server login. The names of the properties are not case sensitive, so property names such as BadPasswordCount and badpasswordcount are equivalent. The values of the PasswordHash, PasswordHashAlgorithm, and PasswordLastSetTime properties are available on all supported configurations of SQL Server, but the other properties are only available when SQL Server is running on Windows Server 2003 and both CHECK_POLICY and CHECK_EXPIRATION are enabled. For more information, see Password Policy.
Requires VIEW permission on the login. When requesting the password hash, also requires CONTROL SERVER permission.
The following example checks whether SQL Server login John3 must change its password the next time it connects to an instance of SQL Server.
SELECT LOGINPROPERTY('John3', 'IsMustChange'); GO