Question: How do I change the password for a user/login in SQL Server?
Answer: In SQL Server, the password is associated with the SQL Server Login. The Login is then mapped to the database user. So to change a password in SQL Server, you need to execute the ALTER LOGIN statement.
The syntax for changing a password in SQL Server (Transact-SQL) using the ALTER LOGIN statement is:
The Login whose password you wish to change. This Login will the one associated with the database user whose password you wish to change.
The new password to assign.
The new hashed value of the password to assign to the Login.
The old password.
It is used when you want to force the password to be changed the first time that the Login is used after the ALTER LOGIN statement.
It will unlock a Login that has been locked out.
It is by default set to OFF. This option determines whether password expiration policy is enforced. You must specifiy CHECK_EXPIRATION = ON when you use the MUST_CHANGE option.
Let's look at how to change a password using the ALTER LOGIN statement in SQL Server (Transact-SQL).
For example:
This ALTER LOGIN example would alter the Login called AODBA and change the password of this login to 'bestsite'.
Let's look at how to change a password and force the password to be changed after the first login using the ALTER LOGIN statement in SQL Server (Transact-SQL).
For example:
This ALTER LOGIN example would alter the Login called AODBA and change the password of this login to 'bestsite'. But because we have specified the MUST CHANGE option and set the CHECK_EXPIRATION to ON, the password will have to be changed again in SQL Server after the first login (following the ALTER LOGIN statement). So in effect, it is like resetting a password to a temporary password for a Login.