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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

RiteshShahCommented:
execute following stored procedure

sp_helpuser

0
Rajkumar GsSoftware 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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2008

From novice to tech pro — start learning today.