Tuesday, May 12, 2015

Get SQL Loginame when you know the password




Did you ever found yourself in a situation where a user knows their sql login password but not username? Well, I did.  I want to share this SQL statement that helps you to retrieve the name of sql login if you know the password.


--will return any name with the same password as in the Check text.
SELECT name FROM sys.sql_logins
WHERE PWDCOMPARE('', password_hash) = 1

No comments: