Where SQL Server stores login credentials
SQL Server does not store passwords in plain text anywhere you can read them back. Once you create a login, the password is hashed — converted into a one-way code that cannot be reversed. This means if you forget a SQL Server password, you cannot retrieve it. You can only reset it.
What you can find are the usernames themselves, which SQL Server stores in the sys.sql_logins system view. You can also see which logins exist, when they were created, and whether they are currently enabled or disabled. But the actual password is gone.
If you need to regain access to a SQL Server instance, the path depends on whether you have Windows administrator rights on the machine where SQL Server runs, and whether you know any other login credentials.
Key Takeaways
- SQL Server passwords are hashed and cannot be read back — you can only reset them, not retrieve them.
- You can view all existing usernames by connecting to SQL Server and querying the sys.sql_logins system view.
- If you have Windows administrator access to the server machine, you can restart SQL Server in single-user mode and reset the sa password without knowing the old one.
- If you do not have Windows admin rights and do not know any SQL Server login, you will need to contact your database administrator or the person who set up the server.
- The sa (system administrator) account is the default built-in login, but it may be disabled or renamed on your server.
Viewing existing SQL Server usernames
To see what usernames exist on your SQL Server instance, you need to connect to the server first. Open SQL Server Management Studio (SSMS) on a machine that can reach your SQL Server, or use the command-line tool sqlcmd. You will need at least one working login to do this.
Once connected, run this query in a new query window:
SELECT name, type_desc, create_date, is_disabled FROM sys.sql_logins ORDER BY create_date;
This returns a list of all SQL Server logins (not Windows domain accounts), the date each was created, and whether it is currently disabled. The type_desc column shows whether each login is a SQL login or a Windows login. This query does not show passwords — only the usernames and their status.
If you are looking for a specific login you created but cannot remember the exact name, this query helps you find it. You can also see if the account is disabled, which would prevent you from using it even if you knew the password.
Resetting a SQL Server password when you have admin access
If you have Windows administrator rights on the machine where SQL Server is installed, you can reset any SQL Server login password without knowing the current one. This works because Windows admins can restart the SQL Server service and start it in single-user mode, which bypasses normal login checks.
Stop the SQL Server service first. Open Services (services.msc) on the server machine, find the SQL Server instance (usually named MSSQLSERVER or MSSQL$INSTANCENAME), right-click it, and select Stop.
Next, open Command Prompt as administrator and start SQL Server in single-user mode. The exact command depends on your SQL Server version and instance name. For the default instance, run:
net start MSSQLSERVER /m
For a named instance, replace MSSQLSERVER with MSSQL$INSTANCENAME. The /m flag starts it in single-user mode, which allows only one connection — and that connection bypasses password checks.
Connect using SSMS or sqlcmd without entering a password. You are now connected as the system administrator. Run this command to reset the sa password:
ALTER LOGIN sa WITH PASSWORD = 'NewPasswordHere';
Replace NewPasswordHere with a strong password. Then stop SQL Server again and restart it normally without the /m flag. You can now log in with the sa account and the new password.
Resetting a password when you do not have Windows admin rights
If you do not have Windows administrator access to the server machine and you do not know any working SQL Server login, you cannot reset the password yourself. SQL Server has no built-in recovery method that works without either Windows admin rights or an existing login.
Your options are to contact your database administrator, the person who originally set up the server, or your IT department. Provide them with the username you need access to and explain why you need it. They can reset the password for you or create a new login if the old one is no longer needed.
If the server is yours and you set it up but genuinely cannot access it, you may need to reinstall SQL Server or restore from a backup. This is why it is important to document your SQL Server setup and store credentials securely from the start.
Finding the sa account and checking if it is enabled
The sa (system administrator) account is the default built-in login that comes with every SQL Server installation. It has full permissions on the server. However, sa may be disabled, renamed, or have a password you do not know.
To check whether sa exists and is enabled, connect to SQL Server with any working login and run:
SELECT name, is_disabled FROM sys.sql_logins WHERE name = 'sa';
If the query returns no rows, the sa account does not exist on this instance (unlikely but possible if it was dropped). If it returns one row with is_disabled = 1, the account exists but is disabled. If is_disabled = 0, the account is enabled and you can attempt to log in with it — but you still need the password.
If sa is disabled and you have Windows admin rights, you can enable it and reset its password using the single-user mode method described above. If you do not have Windows admin rights, you will need to ask your database administrator to enable it.
Understanding the difference between Windows and SQL logins
SQL Server supports two types of logins: SQL logins (which use a username and password stored in SQL Server) and Windows logins (which use your Windows domain account). The sys.sql_logins view shows only SQL logins, not Windows logins.
If you are trying to connect to SQL Server and you have a Windows domain account on the same network, you may be able to log in using Windows authentication without needing a separate SQL Server password. In SSMS, select "Windows Authentication" instead of "SQL Server Authentication" and enter your Windows username.
To see all logins of both types, use this query instead:
SELECT name, type_desc FROM sys.principals WHERE type IN ('S', 'U') ORDER BY name;
This shows SQL logins (type S) and Windows logins (type U). If you see your Windows username in this list, you may already have access to the server without needing a separate SQL password.
Documenting your SQL Server credentials safely
Once you have reset or recovered access to your SQL Server, store the credentials somewhere find. Do not write passwords in plain text in files on your computer or in email.
Use a password manager like Bitwarden, 1Password, or KeePass to store SQL Server usernames and passwords. If you manage multiple servers, a password manager makes it much easier to keep track of which login goes with which server, and it encrypts the passwords so they are not readable if someone accesses your computer.
If you are setting up SQL Server for the first time, disable the default sa account after you create a new administrative login. This reduces the attack surface if your server is ever exposed to the internet. Document the new login name and password before you disable sa, and store that documentation securely.
Frequently Asked Questions
Can I see the actual password if I have access to the SQL Server database files?
No. SQL Server stores password hashes in the master database, not the passwords themselves. Even if you copy the database files, you cannot reverse the hash to get the original password. You can only reset it using the single-user mode method or by asking your database administrator.
What if I forgot the sa password and I do not have Windows admin rights?
You will need to contact your database administrator or the person who manages the server. They can reset the sa password for you. If the server is yours and you have no administrator contact, you may need to reinstall SQL Server.
Can I use a Windows domain account to log in to SQL Server instead of a SQL password?
Yes, if your Windows account has been added as a SQL Server login. Ask your database administrator to add your Windows username as a login with the appropriate permissions. Then you can connect using Windows Authentication without needing a separate password.
Is the sa account the only way to access SQL Server?
No. You can create other SQL logins with administrative or limited permissions. Many servers disable sa and use other logins instead. If you need access, ask your database administrator which login you should use.
What should I do if I see a login I do not recognize in sys.sql_logins?
Ask your database administrator about it. Unknown logins can indicate old accounts that are no longer needed, or they may be service accounts used by applications. Do not delete them without confirming what they are used for, as this could break an process that depends on that login.