Passwords for SQL Server logins are stored as one-way hashes, so there is no built-in command that reads a forgotten password back in plain text. What you can legitimately do is recover access: reset a known login’s password with sysadmin rights, or restart SQL Server in single-user mode when no administrator credentials are available. Both approaches change credentials rather than reveal them. Only accounts configured with SQL Server authentication are affected; Windows-authenticated logins don’t use a password inside SQL Server at all, which is a common source of confusion. Everything below assumes a machine you own or administer.
The phrase “retrieve the password” covers several different situations that get mixed together in practice. Sometimes an application connection string or a saved job still holds a working password and the goal is just to find where it lives. Sometimes the password is truly forgotten and the goal is to regain access. Sometimes the instance has an unrecoverable configuration and the safest route is a fresh login entirely. Sorting out which case you’re in before touching anything saves a lot of avoidable trouble, especially on a production server.
It also helps to know what SQL Server actually stores. For SQL logins, the server keeps a salted hash derived from the password, not the text. That design is deliberate: anyone who copies the system databases gets something that is expensive to reverse. So a “password retrieval” task almost always becomes a credential reset or a search for a stored copy elsewhere in your environment, not a decryption exercise.
What “the password” actually means on a SQL Server instance
There are two authentication paths, and they behave very differently. Windows authentication relies on your domain or local Windows account; SQL Server never sees or stores a password for those logins. SQL Server authentication uses a login name and a password that SQL Server hashes and stores in its own metadata. If the account you’re chasing logs in through Windows, there is nothing to retrieve from SQL Server and nothing to reset there either.
Passwords can also live outside the database engine. An application’s configuration file, an ORM connection string, a scheduled task, a linked server definition, or an integration package may contain a working password in plain text or in a locally encrypted form. Those copies are frequently the realistic answer when the server-side password is unknown but the application keeps connecting successfully. Finding that copy is a documentation and configuration exercise, not a database hack.
Finally, there’s the sysadmin question. Resetting any login’s password requires either an existing sysadmin session or an out-of-band way to get one. If you have a working sysadmin login, recovery is quick and low-risk. If you don’t, you’re in single-user-mode territory, which needs local administrative rights on the server and carries more operational risk. Deciding which branch applies is the first real step.
Before you touch anything: prerequisites and a safety checklist
Make these preparations first, because a half-finished recovery on a live server can be worse than the forgotten password.
1: Confirm you’re authorized. You need ownership of the instance or explicit written authority to administer it. Resetting logins on a system you don’t control is not “recovery.” 2: Confirm the instance name and version. Record it, along with the SQL Server service account and whether the instance is default or named. You’ll need the exact service name for a single-user-mode restart. 3: Take a backup or snapshot of the system databases if your environment and licensing allow it, or at minimum a VM snapshot. A sysadmin reset changes login metadata and, on some paths, can affect permissions if done carelessly. 4: Note every login and its server roles so you can compare before and after. Querying sys.server_principals and sys.server_role_members gives you the baseline. 5: Plan a maintenance window if the instance serves real users. Single-user mode takes the database engine offline for everyone else. 6: Write down what you’ll test: a fresh connection with the new password, an application smoke test, and a check of scheduled jobs.
A quick way to see which logins are SQL-authenticated and which are Windows-based is to query sys.sql_logins for the SQL logins and sys.server_principals for the rest. That tells you immediately whether your target is even a password-bearing login.
Path A: reset a known login when you already have sysadmin access
This is the clean, supported route and the one to try first. It works when you can log in with any account that has the sysadmin server role, or with an account that can otherwise alter the target login.
1: Connect with a sysadmin account using SQL Server Management Studio, Azure Data Studio, or sqlcmd. Verify the privilege with SELECT IS_SRVROLEMEMBER('sysadmin');; a result of 1 confirms it. 2: Locate the target login. Run SELECT name, type_desc, is_disabled FROM sys.server_principals WHERE type IN ('S','U'); to list SQL and Windows logins and their disabled state. 3: Reset the password. For a SQL login, run ALTER LOGIN [LoginName] WITH PASSWORD = 'NewStrongPassword';. If the login is disabled, add , CHECK_POLICY = ON after enabling it, or run ALTER LOGIN [LoginName] ENABLE; separately. 4: Confirm success. Reconnect in a new session using the new password. Expect a successful login and the same permissions the login had before, because you changed the credential, not the roles. 5: Record the change in your credential management system so the next person doesn’t repeat this exercise.
Two cautions matter here. First, ALTER LOGIN on your own account requires the old password in some configurations, so if you’re resetting your own login, plan for that. Second, if the login is mapped to an application, the app will break until you update its connection string; coordinate the change so you don’t trade a password problem for an outage.
Success check: the new session connects, the application’s health check passes, and the login still appears in the same server roles as your baseline. If any of those fail, stop and compare against the baseline before making further changes.
Path B: regain sysadmin access via single-user mode when no admin login works
When nobody knows a sysadmin password, Microsoft’s documented recovery approach is to start the instance in single-user mode and add or reset a sysadmin login. This is a controlled, well-understood procedure, but it is disruptive and easy to get wrong.
1: Stop the SQL Server service for the target instance (for example, the SQL Server (MSSQLSERVER) service for a default instance, or SQL Server (InstanceName) for a named one). 2: Start it in single-user mode from an elevated command prompt: NET START MSSQLSERVER /f /mSQLCMD. The /f starts the instance with minimal configuration, and /mSQLCMD restricts the single connection to the sqlcmd client, which prevents other tools from grabbing the only slot. 3: Connect with sqlcmd from the same machine as a local administrator: sqlcmd -S . -E. Windows authentication via the local admin account is the usual path in this mode. 4: Add your Windows account as a sysadmin, or reset a SQL login: CREATE LOGIN [DOMAIN\YourUser] FROM WINDOWS; ALTER SERVER ROLE sysadmin ADD MEMBER [DOMAIN\YourUser];. Alternatively, ALTER LOGIN [sa] WITH PASSWORD = 'NewStrongPassword'; and enable it if needed. 5: Stop and restart the service normally, without the /f /m flags, so the instance returns to multi-user operation. 6: Verify by connecting with the new sysadmin account and confirming IS_SRVROLEMEMBER('sysadmin') returns 1.
The failure modes are worth knowing in advance. If another process grabs the single connection before your sqlcmd session, you’ll get an error and need to stop and restart the service. If the service won’t start with /f, check the error log for startup failures and resolve those before retrying. And if you’re on a cluster or an Always On availability group, this procedure needs coordination with the availability design; that’s a stop condition where a database administrator or Microsoft support should take over.
When the password isn’t the real problem: hunting stored copies elsewhere
Sometimes the fastest legitimate recovery is finding a working password that a system already uses. An application that still connects to SQL Server must be storing the credential somewhere, and that copy is often readable by administrators. Common locations include application configuration files, connection strings in deployment manifests, scheduled task definitions, linked server definitions in other instances, and secrets stores your organization already uses.
The disciplined way to search is to start from the application’s documentation and deployment pipeline rather than scanning disks blindly. If the app has a health check that passes, its configuration holds a valid credential. Retrieving it from a secrets manager with proper authorization is legitimate; scraping it from an unsecured file on a shared drive is a governance problem even when technically possible.
Encrypted stored credentials, such as linked server passwords or saved connection strings protected by the local machine key, can sometimes be read back on the same machine by the same service account. That’s a supported behavior of the local encryption, not a way around SQL Server’s password hash. Treat anything you recover this way as a credential to rotate, because it has now been handled outside its normal lifecycle.
The hashing reality: why you can’t just “read” a SQL Server password
SQL Server stores password verifiers derived from the password, not the password itself. That means a database administrator who can query the system tables still can’t output the original text. Tools that claim to “recover” SQL Server passwords are generally doing one of three things: brute-force or dictionary attacks against the hash offline, resetting the login, or extracting a plain-text copy from a different store. The first can take a very long time and only succeeds for weak passwords; the second is Path A; the third is the stored-copy hunt above.
For planning purposes, treat hash cracking as a last resort with unpredictable timing and no guarantee. If the account is a sysadmin, resetting is faster and safer. If the account is an application login you can’t reset without breaking the app, the stored copy in the app’s configuration is the realistic source. Old backups of the master database are another theoretical avenue, but they hold the same hashes, so they don’t bypass the fundamental limit.
Edge cases: contained databases, Azure SQL, and service accounts
A contained database user with a password lives inside that database rather than at the server level. Resetting it follows the same principle but uses database-scoped syntax: ALTER USER [UserName] WITH PASSWORD = 'NewStrongPassword'; while connected to that database as someone with the right permissions. The server-level login may not exist at all in that design, so don’t go looking for it.
Azure SQL Database and Azure SQL Managed Instance work differently again. In Azure SQL Database, administrative password recovery is handled through the Azure portal’s reset flow for the server admin, not through single-user mode, and you shouldn’t attempt the /f /m procedure there. Managed Instance allows some of the same T-SQL resets once you have sysadmin access, but platform-level recovery belongs with the Azure control plane. Check your service’s documentation before assuming the on-premises procedure applies.
Service accounts are a separate trap. A SQL Server service running under a Windows account doesn’t have a SQL password to retrieve; its credential is managed by Windows. If someone “forgot the SQL Server password” but the service is running fine, the thing they actually need may be the Windows service account, which is outside SQL Server’s scope entirely.
Choosing the right path without breaking production
The decision comes down to what you actually have. If you can log in as sysadmin, use Path A: it’s fast, reversible in effect, and doesn’t require downtime. If you have no administrative SQL login but do have local administrator rights on the server, Path B restores control at the cost of a maintenance window. If the application is still connecting, check its configuration and secrets store before doing either, because you may not need to touch the database at all.
| Situation | Best first move | Downtime | Main risk |
|---|---|---|---|
| You have a sysadmin login | ALTER LOGIN reset | None | App breaks until connection string updated |
| No SQL admin login, local admin available | Single-user mode, add sysadmin | Yes, instance offline | Single connection lost to another process |
| App still connects successfully | Recover stored credential from config or secrets store | None | Handling a live credential carelessly |
| Contained database user | Database-scoped ALTER USER | None | Wrong database context |
| Azure SQL Database | Azure portal admin reset | Minimal | Using on-premises procedure incorrectly |
Test the result in this order: connect with the new credential in a fresh session, run one representative application query, and check that scheduled jobs still run under their expected logins. If any of those fail, revert to your baseline notes before making more changes. That sequence catches most mistakes quickly.
Reducing the chance you’ll need this again
The recurring cause of password-recovery emergencies is credentials that live in one person’s head. Move SQL logins into a secrets manager with access controls and audit logs, document which application uses which login, and rotate credentials on a schedule so rotation is routine rather than a crisis. Keep a break-glass procedure for single-user-mode recovery written down and tested in a lab, so the first time anyone runs it isn’t during an outage.
Also narrow the blast radius. Applications should connect with least-privilege logins rather than sysadmin accounts, so a forgotten application password never becomes a forgotten sysadmin password. That single practice prevents the most painful version of this problem, where the only working credential is also the one with the most power.
If your instance is clustered, replicated, or managed by a platform service, the stop condition is clear: once the recovery path requires touching availability group configuration, replication topology, or a cloud control plane you don’t administer, hand it to a qualified database administrator or the platform’s support channel rather than improvising.