7

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?

migrated from stackoverflow.com Dec 2 '11 at 21:35

This question came from our site for professional and enthusiast programmers.

  • 1
    FYI, syslogins is deprecated to sys.server_principals whic still doesn't have it. Nor sys.sql_logins – gbn Dec 2 '11 at 21:41
19

Use the PasswordLastSetTime option of the LOGINPROPERTY.

SELECT LOGINPROPERTY('YourLoginName', 'PasswordLastSetTime');
  • 1
    Appreciate the time Joe, thanks; it worked fine. Heads up for those using windows integrated authentication, it will return NULL because login_name must be the name of a SQL Server login. – Only You Dec 5 '11 at 13:57
-4

select name, create_date from sys.sql_logins

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.