Search code examples
sql-serversql-server-2000

How to tell whether a database login is disabled without using the GUI in a select query


I have been searching for an answer for the last 30 minutes on google, but haven't been able to find a satisfactory answer.

I am able to retrieve a list of db logins from the syslogins table, but it doesn't contain a field to indicate whether the login is disabled. I need to use this in a select query. Can anyone enlighten me?

Note that this applies to sql server 2000.


Solution

  • select name, hasaccess
    from sys.syslogins
    

    I believe the field hasaccess is what you are looking for. As per MSDN, hasaccess is 1 if the login has access to the instance, and 0 if not.