HiveBrain v1.2.0
Get Started
← Back to all entries
snippetMajor

How to find the date a login password was last changed in SQL Server 2008?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
lastthehow2008serversqllogindatepasswordfind

Problem

I'm porting stored procedures from Sybase 15 to SQL Server 2008.

In Sybase this statement calcs an expiration date by adding a number of days to syslogins.pwdate (Date the password was last changed) and works fine:

SELECT @l_pwd_date = dateadd( day, @l_pwd_max_expire, pwdate)
FROM master.dbo.syslogins
WHERE name = @v_user


...but throws this error when trying to compile it in SQL Server 2008:


Msg 207, Level 16, State 1, Line 21 Invalid column name 'pwdate'.

syslogins in SQL Server 2008 no longer includes that column pwdate.

Does anyone know where could I find equivalent column in SQL Server 2008 or a workaround to find the date a login password was last changed?

Solution

Use the PasswordLastSetTime option of the LOGINPROPERTY.

SELECT LOGINPROPERTY('YourLoginName', 'PasswordLastSetTime');

Code Snippets

SELECT LOGINPROPERTY('YourLoginName', 'PasswordLastSetTime');

Context

StackExchange Database Administrators Q#8720, answer score: 22

Revisions (0)

No revisions yet.