You can't recover an MS SQL password in plaintext, because SQL Server stores a one-way hash of it. What you can do is get back into the instance: reset the password of a SQL login while you have sysadmin rights (or Windows admin access to the server), or recover a forgotten application password from a saved connection file or your own source code. In Microsoft's terminology, "MS SQL" usually means SQL Server, so the steps below apply to SQL Server 2016 through 2025 on Windows and Linux; Azure SQL Database is different and gets a short note. The key condition is which account you control—Windows admin on the host, another sysadmin login, or neither—because that determines which route is open.

First, separate three different "passwords"

People ask this question with three different things in mind, and the answer changes for each:

A SQL Server login password you forgot (for example, the sa account or an application login). This is a credential checked by the database engine against a hash stored in the master database. It cannot be decrypted back to text. A password stored by a client—a saved connection in SQL Server Management Studio (SSMS), a linked server, a SQL Server Agent job step, or an application's connection string. Some of these are encrypted reversibly with keys the server or your Windows profile holds, so they can be read back under the right conditions. A database-level password such as a master key password or a backup encryption password. These protect encryption hierarchies; a forgotten one usually means data is unrecoverable without the escrowed copy.

The rest of this article follows that split, because the practical mistake is spending time on the wrong one.

What SQL Server actually stores (and why "recovery" isn't decryption)

A SQL login's password is hashed with SHA-512 (current versions) or the older SHA-1 algorithm, salted, and stored in sys.sql_logins. When you log in, the server hashes what you typed and compares. There is no stored plaintext and no vendor-supported "show me the password" command. Third-party tools that advertise password recovery for SQL logins are doing one of three things: dictionary and brute-force guessing against the hash, reading a saved credential from a client or script, or simply resetting the login for you. Knowing which one you're paying for matters, because only the first is real cracking and it succeeds only against weak passwords.

That's also why the honest framing of this task is "regain access and set a new password," not "retrieve the old one." For most people, that's the outcome they actually want.

Route 1: Reset a SQL login when you still have sysadmin access

This is the clean path and requires no downtime. Prerequisites: you can connect to the instance with a login that is a member of the sysadmin fixed server role—often your Windows account if you installed SQL Server with mixed-mode authentication.

1: Connect with SSMS, Azure Data Studio, or sqlcmd using Windows Authentication or the working sysadmin login. 2: Confirm your rights by running SELECT IS_SRVROLEMEMBER('sysadmin');. A result of 1 means you can proceed. 3: Reset the target login: ALTER LOGIN [app_user] WITH PASSWORD = 'NewStrongPassword!'; If you're resetting your own login and don't want to force a change at next logon, add OLD_PASSWORD = '...' only when you know the old one—otherwise omit it; it's optional for a sysadmin resetting another login. 4: If the login is disabled or locked, re-enable it in the same statement: ALTER LOGIN [app_user] WITH PASSWORD = '...', CHECK_POLICY = ON; then ALTER LOGIN [app_user] ENABLE;. 5: Check success by opening a new connection using the login with the new password. Don't trust the existing session; authentication is what you're testing.

Two cautions. First, ALTER LOGIN doesn't change the password inside application connection strings, Scheduled Jobs, or linked servers—those will start failing until you update them, so list them first with SELECT * FROM sys.sql_logins and search your job steps. Second, if the login owns a database or schema, resetting the password doesn't affect ownership; that's a separate concern.

Route 2: Reset a SQL login when you're a Windows administrator on the host

If no SQL login works but you have local administrator rights on the server, you can grant yourself sysadmin temporarily. This is the standard documented recovery procedure and requires a service restart, so plan a maintenance window.

1: Check the authentication mode first. If the instance is Windows-only authentication, you may already be able to connect with a Windows admin account and skip to Route 1. If it's mixed mode and you've lost every SQL sysadmin, continue. 2: Stop the SQL Server service for the instance (Service Manager, net stop MSSQLSERVER, or systemctl stop mssql-server on Linux). 3: Start it in single-user mode as a local admin. From an elevated command prompt, run net start MSSQLSERVER /m"SQLCMD" (the /m flag is single-user mode; the "SQLCMD" argument restricts the single connection to the sqlcmd tool). On Linux, use sudo -u mssql /opt/mssql/bin/sqlservr -m"SQLCMD" in one terminal. 4: Connect immediately with sqlcmd -S localhost -E (Windows Authentication) before anything else grabs the single connection. Background services may race you for it. 5: Grant yourself sysadmin: CREATE LOGIN [DOMAIN\YourAdmin] FROM WINDOWS; then ALTER SERVER ROLE sysadmin ADD MEMBER [DOMAIN\YourAdmin];. Close the session. 6: Restart normally (stop and start the service without the /m flag), then connect with your Windows account and use Route 1 to reset whichever SQL login you actually need. 7: Verify by logging in as the recovered account, then remove or review the temporary grant if you added one you don't want to keep.

Failure modes to expect: the connection is refused because another process took the single slot, the account you're using isn't a local admin, or the instance is a named instance and you need /m"SQLCMD" with the correct instance name. If it's a clustered or Always On availability group instance, stop here—single-user recovery on a cluster has its own considerations and belongs with a DBA.

Route 3: Read back saved credentials from clients and scripts

If what you've forgotten is the password your application or tool uses, the database may not be the right place to look. Under the right conditions, these sources are reversibly encrypted and can be read:

SSMS saved connections and registered servers. Passwords saved in SSMS connection dialogs are encrypted per Windows user with DPAPI; a tool running as that same user can decrypt them. That's why copying SSMS's cache to another machine rarely works. Application connection strings in web.config/appsettings.json, environment variables, or secret stores—usually just sitting there in plaintext or protected with a key you control. Linked servers and SQL Server Agent job steps. Linked server passwords are stored encrypted with the service master key; as sysadmin you can inspect the definition, but the password itself shows as masked. A Job step running a PowerShell or CmdExec command may embed credentials in its command text, which you can read with sp_help_jobstep.

The practical check: search your configuration files and secret manager for the database hostname before assuming the password lives in SQL Server at all. In my experience, a large share of "lost SQL password" tickets end this way.

Route 4: Reading the hash and attacking it (and why it usually disappoints)

Because the login's hash lives in sys.sql_logins.password_hash, a sysadmin can extract it and run a cracking tool offline. This is legitimate on systems you own; it's also where expectations should be calibrated. SHA-512 hashing with salting is not fast to brute-force, and a long random password is effectively out of reach. The technique only pays off for short or dictionary-based passwords, and it is strictly slower and riskier than Route 1—use it when you need to know what the old password was (say, to recover an app's expected value) rather than merely to get in. If you already have sysadmin rights, resetting is faster and safer; if you don't, the hash isn't reachable anyway. Treat cracking as an audit exercise against your own instance, not a recovery plan.

Route 5: Master key and backup encryption passwords

These don't follow the login rules, and it's worth saying plainly because people conflate them. A database master key password can be regenerated by someone who is sysadmin in that database using ALTER MASTER KEY REGENERATE WITH ENCRYPTION BY PASSWORD = '...'—which re-encrypts the key with a new password without needing the old one. However, if the master key password was the only protection (no service master key or other key chain), regenerating it can strand data encrypted under it. Backup encryption passwords are worse: without the password or a copy in a password manager, a TDE- or backup-encrypted file cannot be restored, and no supported reset exists. The lesson is to escrow these out-of-band before you need them, and if you're staring at this now, that's the point to involve your DBA or Microsoft support rather than experiment on production.

What "MS SQL" doesn't mean here

Two scope notes keep this accurate. Azure SQL Database has no sa login and no single-user recovery: you reset a contained database user's password by connecting as an administrator (Entra ID admin or the server admin) and running ALTER USER ... WITH PASSWORD = '...', and if you've lost all admin access, the supported path is the Azure portal's admin reset or Microsoft support—not service restarts, because you don't have the host. SQL Server on Linux follows Route 2 with the sqlservr -m command above but runs the engine as the mssql user, so the permissions and service-manager steps differ from Windows. And SSMS or Azure Data Studio forgetting your saved password is a Route 3 problem, not a server one.

When to stop and call someone

If you've lost every sysadmin login and you don't have Windows admin rights on the host, there is no supported self-service path—the fix requires host access you don't have, and guessing at registry edits or file replacements risks corrupting the instance. Stop and engage your infrastructure team or a DBA. The same applies if the instance is part of an availability group, if the missing credential is a backup-encryption or TDE protector password with no escrow, or if this is production and the service restart in Route 2 would breach a maintenance agreement. For a personal test instance, Route 2 with a single-user start is routine and reversible; on anything shared, it's a change-management decision.

A sensible order to try these

Work from least to most disruptive: check your own configs, secret stores, and SSMS for a saved password (Route 3); try any other sysadmin login you might hold and reset (Route 1); only then consider the single-user restart (Route 2); reserve hash extraction (Route 4) for audits where knowing the old password matters. Have a colleague confirm you can reach the instance after each step, because success is defined by a fresh login working with the new credential—not by the tool reporting success. And once you're back in, rotate the credential, update the application strings and job steps that referenced it, and record the new one in your password manager so the next search starts and ends there.