get a list of all users in SQL Server with account status (Active/Inactive or Enabled or disabled)

Hi friends,

Is there a way to get a list of users in SQL Server 2005 db with status of their account. A sql or something?

When I tried to test a disabled user via ODBC I get SQL Server Error: 18470 SQL State: 42000.

But would like have a sql to get user accont status.

THANKS IN ADVANCE
grind67Asked:
Who is Participating?
 
Rajkumar GsConnect With a Mentor Software EngineerCommented:
Try this query

Raj
select name, type, case is_disabled when 0 then 'Active' else 'Disabled' end Status, 
create_date from sys.server_principals
where type = 'S'

Open in new window

0
 
RiteshShahCommented:
execute following stored procedure

sp_helpuser

0
 
geek_vjCommented:
You can try this -

select * from sys.sql_logins

Under the result set, check the values under column 'is_disabled'

if 1, then it is disabled, if 0, then it is enabled
0
 
RiteshShahCommented:
apart from the query given above by expert, here is one good article, worth reading it.

http://milambda.blogspot.com/2010/01/what-permissions-does-principal-have.html

0
All Courses

From novice to tech pro — start learning today.