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

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.


Reducing the join:

select name, is_disabled from sys.sql_logins where is_disabled=1 order by 1


use sys.sql_logins for checking enable/disable status of login. example

select * from syslogins sl
join 
sys.sql_logins sql
 on sl.sid=sql.sid
where is_disabled=1