—
— Retrieves Security-Related Information
— for all the SQL Server Logins
—
— SQL Server versions supported: SQL Server 2005 or later
—
SELECT
[name] as LoginName,
LOGINPROPERTY ([name] , ‘DefaultDatabase’) as DefaultDatabase,
LOGINPROPERTY ([name] , ‘DaysUntilExpiration’) as DaysUntilExpiration,
(CASE ISNULL(LOGINPROPERTY ([name] , ‘IsExpired’),0) WHEN 0 THEN ‘False’ ELSE ‘True’ END) as IsExpired,
(CASE ISNULL(LOGINPROPERTY ([name] , ‘IsLocked’),0) WHEN 0 THEN ‘False’ ELSE ‘True’ END) as IsLocked,
LOGINPROPERTY ([name] , ‘PasswordLastSetTime’) as PasswordLastSetTime,
LOGINPROPERTY ([name] , ‘PasswordHashAlgorithm’) as PasswordHashAlgorithm
FROM master..syslogins
— Retrieves Security-Related Information
— for all the SQL Server Logins
—
— SQL Server versions supported: SQL Server 2005 or later
—
SELECT
[name] as LoginName,
LOGINPROPERTY ([name] , ‘DefaultDatabase’) as DefaultDatabase,
LOGINPROPERTY ([name] , ‘DaysUntilExpiration’) as DaysUntilExpiration,
(CASE ISNULL(LOGINPROPERTY ([name] , ‘IsExpired’),0) WHEN 0 THEN ‘False’ ELSE ‘True’ END) as IsExpired,
(CASE ISNULL(LOGINPROPERTY ([name] , ‘IsLocked’),0) WHEN 0 THEN ‘False’ ELSE ‘True’ END) as IsLocked,
LOGINPROPERTY ([name] , ‘PasswordLastSetTime’) as PasswordLastSetTime,
LOGINPROPERTY ([name] , ‘PasswordHashAlgorithm’) as PasswordHashAlgorithm
FROM master..syslogins
For more info, check out the following links:
Artemakis Artemiou, a distinguished Senior Database and Software Architect, brings over 20 years of expertise to the IT industry. A Certified Database, Cloud, and AI professional, he earned the Microsoft Data Platform MVP title for nine consecutive years (2009-2018). As the founder of SQLNetHub and GnoelixiAI Hub, Artemakis is dedicated to sharing his knowledge and democratizing education on various fields such as: Databases, Cloud, AI, and Software Development. His commitment to simplicity and knowledge sharing defines his impactful presence in the tech community.