Adds or changes a password for a Microsoft SQL Server login.
This feature will be removed in a future version of Microsoft SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature. Use ALTER LOGIN instead.
Applies to: SQL Server (SQL Server 2008 through current version).
sp_password calls ALTER LOGIN. This statement supports additional options. For information on changing passwords, see ALTER LOGIN (Transact-SQL).
sp_password cannot be executed within a user-defined transaction.
A. Changing the password of a login without knowing the old password
The following example shows how to use ALTER LOGIN to change the password for the login Victoria to B3r1000d#2-36. This is the preferred method. The user that is executing this command must have CONTROL SERVER permission.
ALTER LOGIN Victoria WITH PASSWORD = 'B3r1000d#2-36'; GO
B. Changing a password
The following example shows how to use ALTER LOGIN to change the password for the login Victoria from B3r1000d#2-36 to V1cteAmanti55imE. This is the preferred method. User Victoria can execute this command without additional permissions. Other users require ALTER ANY LOGIN permission.
ALTER LOGIN Victoria WITH PASSWORD = 'V1cteAmanti55imE' OLD_PASSWORD = 'B3r1000d#2-36'; GO