views:

30

answers:

2
+1  Q: 

SQL Server Login

What is the SQL query to check whether particular SQL Login is Enable or Disable?

+3  A: 
SELECT is_disabled FROM sys.server_principals WHERE name = @name;

Updated after OP question:

'guest' is not a login (server principal) is an user (database principal) so you need to look for it in sys.database_principals. Users cannot be enabled nor disabled, they simply exist or don't exist. guest is a special built-in user that maps all server principals that are not explicitly mapped to another user: that is server principals (logins) that have access to the database but do not have a database principal (user) with a matching SID will be mapped to 'guest'. Except members of sysadmin role which are always mapped to dbo.

Remus Rusanu
Thank You Very Much
John
A: 
SELECT name, type_desc, is_disabled
FROM sys.server_principals
WHERE name = 'sa'

Replace 'sa' with your desired login.

Oliver
Thank You Very Much
John
When i run the below Query its doesn't show me the guest user status, where its enable or disable. SELECT name, type_desc, is_disabled FROM sys.server_principals
John