News We Recently Launched AD Migrator and AD Reporter | News SysTools Commitment to Child Safety: Upholding the Fight Against CSAM |

How to Find List of Users in SQL Server Database?

  author
Written By Andrew Jackson
Anuraag Singh
Approved By Anuraag Singh
Published On January 7th, 2025
Reading Time 7 Minutes Reading

find all logins in SQL Server

If you’re trying to find list of users in SQL Server, then this is the right article for you. Here, we’re going to learn how to get all SQL logins in a server using both manual & advanced methods. Moreover, apart from helping users to learn how to get all SQL logins in a server, we are going to add the reasons, benefits & drawbacks of these methods, and most asked questions.

This is indeed a simple problem which users can fix with a little technical knowledge or the leverage of a reliable tool.

How A User & Its Information Table Looks Like?

Now, we have some queries for getting the users’ list and some for getting users’ and their roles list. Their ways to find all logins in SQL Server might be different and so their results will be. So, let’s have a look what information users might expect when they ask for the list of users and their roles using the manual solution.

Basis Explanation
Name Name of the User Assigned at the Time of Creation
Principal_ID Numeric Value – (Unique)
Type Type of Principal

 

S = SQL Server User

U = Windows User

G = Windows Group

A = Application Role

R = Database Role

C = Certificate Mapped

K = Asymmetric Key Mapped

Type_DESC Description for Type of Principal

SQL_USER

WINDOWS_USER

WINDOWS_GROUP

APPLICATION_ROLE

DATABASE_ROLE

CERTIFICATE_MAPPED_USER

ASSYMETRIC_KEY_MAPPED_USER

Default_Schema_Name Name to Use in the Absence of Schema
Create_Date Date/Time at The Time of User Creation
Modify_Date Date/Time When User Was Modified
Owning_Principal_ID ID of the Principal that Owns this User
Is_Fixed_Role 0 or 1
Authentication_Type NONE, WINDOWS, INSTANCE
Default_Language_Name
Default_Language_lcid

Now, we hope, users might be aware of what exactly they’ll get as a result of using the manual solution. However, it might be a bit dangerous because the manual method being too complex for beginners.

Why Get All SQL Logins in A Server?

There are numerous scenarios where users need to have the lits of users or their information to complement other events with ease. Let’s understand these reasons why users ned to find all users in SQL Server database.

Primarily, we have three major categories under which all the reasons redies.

Security Audits and Compliance:

  • Compliance Requirements – If organizations are following some of the industry standards like PCI DSS, HIPAA, etc, they need to regularly audit the user access for better security.
  • Identify Unauthorized Access – By getting a list of all user logins in SQL, users can keep an eye on unauthorized access that is generally not detected. Again, it works as a security measure.
  • Risk Analysis and Management – To get an estimate of the overall risk factor, assessing the user access & keeping an eye on it really helps. Users can prepare for the disaster way earlier on the basis of potential risk.

Account Management & Maintenance:

  • Inactive Account Identification – Admins need to find list of users in SQL Server in order to find inactive user account logins. This reduces attack surface & makes the security one level stronger.
  • Password Policy Enforcement – Frequent reviews of the account logins show that everybody is following strong password policies. Thus, user analysis can become easier than it used to be.
  • Account Lockout Monitoring – Closely monitoring and tracking failed login attempts can help admins find potential brute-force & compromised user accounts timely. Thus, any mis happening can be avoided.

Troubleshooting & Performance Monitoring:

  • Network & Connection Issues – Having a list of all logins or user accounts can help in case of database experiences any connection or network issues.
  • Performance Bottlenecks – To find out performance issues, it’s crucial to pinpoint the accounts with high resource usage.

Method #1 Manually Find All Users in SQL Server

This method generally requires T-SQL commands to provide users with their desired results.

Now, we have two scenarios. Either, we need to get the admin/owner details or we need a list of other users. Therefore, manually, we have two commands each. Let’s understand them both & then we will proceed toward the automated solution.

For SQL Server Owner, run this command – 

select suser_sname(owner_sid) as 'Owner', state_desc, *
from sys.databases

To Find All Logins in SQL Server (Full Users List) – 

select * from master.sys.server_principals

Now, let’s move ahead toward the automated method which unleashes a lot of new features.

Method #2 Find List of Users in SQL Server Automatically

Now, if users don’t want to execute the manual & risky T-SQL solution, they can rely on the automated SysTools SQL Password Recovery Tool. This not only recovers the password but also helps users get the list of all users in the SQL Server database.

Download the tool & then follow the four simple steps to find all users in SQL Server automatically for free.

Step-1. Launch the Software after successful installation.

launch tool

Step-2. Hit the Browse button to Add MDF files in it.

browse MDF files

Step-3. Preview User List & Login Details here.

preveiw user lists

Step-4. Reset Passwords if required to finish.

reset passwords

Benefits of Opting for the Advanced Software

Now, it’s time that we know what makes the automated solution better than the others. To put it simply, we can say that the automated tool has some unique features that users must be aware of to utilize it completely.

  • Views the list of individual & SA users along with resetting their passwords feature.
  • It can also recover lost SQL SA password without any hassles from MDF data files.
  • MDF file in the system is enough to get the users list without any hassles at all.
  • No need to have an SQL Server environment in the system to get the list.
  • Ability to reset new passwords or even multi-lingual passwords for users.
  • The latest SQL files till version 2022 are supported by this application.

Moreover, the best benefits of using such a solution are being secure and able to get the results without any complex commands. Thus, beginners can also rely on this.

The Final Say

Now, we know how to find list of users in SQL Server using both manual as well as automated solutions. Both the solution works, and users can opt for the one as per their requirements. Moreover, let’s dive into the FAQs to know what users search to get all SQL logins in a server & its related topic.

FAQs

Q-1. How do I show users in SQL?

Ans: Run the following command to show users in SQL Server database:

SELECT user FROM mysql. User;

Q-2. Which method is reliable as per Microsoft MVPs?

Ans: Both manual and automated solutions work well and users can select any of them. However, to simplify the entire operation, MVPs recommend the automated method.

Q-3. What is DESC in SQL?

Ans: Once, users execute the Create command to make a table, the DESC command is used to see its structure.

  author

By Andrew Jackson

I am SQL DBA and SQL Server blogger too. I like to share about SQL Server and the problems related to it as well as their solution and also I do handle database related user queries, server or database maintenance, database management, etc. I love to share my knowledge with SQL Geeks.