Advertisement
Lulz-Tigre

Login Queries

Jun 17th, 2017
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 0.65 KB | None | 0 0
  1. Get the list of all Login Accounts in a SQL Server
  2.  
  3. SELECT name AS Login_Name, type_desc AS Account_Type
  4. FROM sys.server_principals
  5. WHERE TYPE IN ('U', 'S', 'G')
  6. and name not like '%##%'
  7. ORDER BY name, type_desc
  8. Get the list of all SQL Login Accounts only
  9.  
  10. SELECT name
  11. FROM sys.server_principals
  12. WHERE TYPE = 'S'
  13. and name not like '%##%'
  14. Get the list of all Windows Login Accounts only
  15.  
  16. SELECT name
  17. FROM sys.server_principals
  18. WHERE TYPE = 'U'
  19. Get the list of all Windows Group Login Accounts only
  20.  
  21. SELECT name
  22. FROM sys.server_principals
  23. WHERE TYPE = 'G'
  24. Note: Requires ALTER ANY LOGIN server permission to be able to view all the logins.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement