Adds or changes a password for a Microsoft® SQL Server™ login.
sp_password [[@old =] 'old_password',] {[@new =] 'new_password'}
[,[@loginame =] 'login']
0 (success) or 1 (failure)
SQL Server passwords can contain from 1 to 128 characters, including any letters, symbols, and numbers.
The new password is updated and stored in an encrypted form so that no user, not even system administrators, can view the password.
sp_password cannot be used with Microsoft Windows NT® security accounts. Users connecting to SQL Server through their Windows NT network account are authenticated by Windows NT, therefore their passwords can be changed only in Windows NT.
sp_password cannot be executed within a user-defined transaction.
Execute permissions default to the public role for a user changing the password for his or her own login. Only members of the sysadmin role can change the password for another user’s login.
This example changes the password for the login Victoria to ok.
EXEC sp_password NULL, 'ok', 'Victoria'
This example changes the password for the login Victoria from ok to coffee.
EXEC sp_password 'ok', 'coffee'
sp_addlogin | sp_revokelogin |
sp_adduser | System Stored Procedures |
sp_grantlogin |