How can I forget the SA User Password of SQL Server?
Ms SQL Server is installed on both the desktop and the current version to facilitate testing.
After a long time, the password of the desktop SQL Server was forgotten ......
Don't you ...... No way? -- No!
After a while, you found the method in Baidu:
Of course, your Enterprise Manager cannot enter, but we still have a query analyzer.
During authentication, you choose to follow the Windows authentication, and then go directly ...... Khan!
Run the following command:
Exec sp_password null, 'new password', 'sa'
Now the password has changed. Go to the Enterprise Manager and check ^_^.
The following is a description of the sp_password stored in the SQL Server:
Sp_password
Add or change the password for Microsoft SQL Server logon.
Syntax
Sp_password [[@ old =] 'old _ password',]
{[@ New =] 'new _ password '}
[, [@ Loginame =] 'login']
Parameters
[@ Old =] 'old _ password'
Is the old password. Old_password is of the sysname type, and its default value is null.
[@ New =] 'new _ password'
Is the new password. New_password is of the sysname type and has no default value. If the name parameter is not used, you must specify old_password.
[@ Loginame =] 'login'
Is the login name affected by the password change. Login is of the sysname type, and its default value is null. Login must already exist and can only be specified by members of the SysAdmin fixed server role.
Return code value
0 (successful) or 1 (failed)
Note
The SQL Server password can contain 1 to 128 characters, including any letters, symbols, and numbers.
The new password is updated and stored in encrypted form. Therefore, no user (or even System Administrator) can view the password.
When members of SysAdmin or securityadmin fixed server roles use sp_password with all three parameters to reset their own passwords, the review records reflect that they are changing others' passwords.
Sp_password cannot be used for Microsoft Windows NT Security Accounts. Users who connect to SQL Server through a Windows NT network account are authorized by Windows NT, so their passwords can only be changed in Windows NT.
Sp_password cannot be executed in a user-defined transaction.
Permission
By default, the execution permission is granted to the public role for users to change their logon passwords. Only members of the SysAdmin role can change the logon password of other users.
Example
A. Change the logon password without the original password
The following example changes the password for logging on to Victoria to OK.
Exec sp_password null, 'OK', 'victoria'
B. Change the password
In the following example, the password for logging on to Victoria is changed from OK to coffee.
Exec sp_password 'OK', 'coffee'