Sql-server – Logins mapped to dropped database sql server

sql server

I was told to delete the logins that are mapped to a database ABC but unfortunately the database ABC has been dropped and no backups exist.

Is it possible to find the logins that WERE mapped to ABC?

Best Answer

Try the following query:

SELECT * FROM syslogins WHERE dbname = 'ABC'

If there are logins still using that as their default database, this should help you find them. However, if the users had a default database of master and the application performed a USE ABC command, then you'll have no way of knowing they were tied to the application. It's only if the application was kind enough to create your SQL logins with a default database of 'ABC' will you be able to track things down.