ALTER LOGIN … WITH PASSWORD lets you change a SQL Server logins password, optionally validating the old password and enforcing policy rules.
ALTER LOGIN is the fastest, safest way to rotate SQL Server passwords without recreating logins or disrupting permissions.
Scripts are auditable, repeatable, and can be automated in CI/CD pipelinescritical in engineering-heavy teams.
Use ALTER LOGIN login_name WITH PASSWORD = 'newPwd'; The statement runs in <80 ms on most systems.
Connect with your login and supply OLD_PASSWORD for extra safety:
ALTER LOGIN CURRENT_USER WITH PASSWORD = 'N3wStr0ng!' OLD_PASSWORD = 'CurR3nt!';
Sysadmins skip OLD_PASSWORD:
ALTER LOGIN ecom_app WITH PASSWORD = 'Sup3rS3cur3!';
Add CHECK_POLICY = ON | OFF and CHECK_EXPIRATION = ON | OFF depending on compliance needs.
Not directly. Combine ALTER LOGIN with ALTER LOGIN ... MUST_CHANGE
in Windows Authentication or use AD.
1) Always use strong, generated passwords. 2) Run GRANTs on new logins in a transaction. 3) Rotate secrets in the app config immediately after ALTER LOGIN completes.
See the dedicated section below to keep outages away.
Query sys.sql_logins:
SELECT name, password_last_set_time FROM sys.sql_logins WHERE name = 'ecom_app';
No. Existing connections stay alive. Only new connections require the new password.
No. Use ALTER USER WITH PASSWORD inside the contained database instead.
Never. SQL Server hashes the password before storing it in sys.sql_logins.