Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 204
  • Last Modified:

SQL User list to include status

I am looking to generate a list of all users in SQL that will include the SQL login name plus their current status(i.e. whether their SQL account is locked or not).
0
rwheeler23
Asked:
rwheeler23
  • 2
2 Solutions
 
Phillip BurtonDirector, Practice Manager and Computing ConsultantCommented:
select [name], is_disabled from sys.server_principals
where type_desc = 'SQL_LOGIN'

Open in new window

0
 
Vitor MontalvãoMSSQL Senior EngineerCommented:
You can try this query:
SELECT loginname, CASE LOGINPROPERTY(loginname,'IsLocked') 
						WHEN 0 THEN 'No'
						WHEN 1 THEN 'Yes'
						ELSE 'Domain User'
					END IsLocked
FROM sys.syslogins
WHERE hasaccess=1

Open in new window

0
 
rwheeler23Author Commented:
Thank you gentlemen, one script shows disabled logins and the other shows locked logins.
0
 
rwheeler23Author Commented:
Thank you.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

A proven path to a career in data science

At Springboard, we know how to get you a job in data science. With Springboard’s Data Science Career Track, you’ll master data science  with a curriculum built by industry experts. You’ll work on real projects, and get 1-on-1 mentorship from a data scientist.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now