简体   繁体   中英

How do I script a password change for a SQL server login?

正如标题所说,我需要更改现有sql server登录的密码,我想通过sql脚本来完成。

If the user already has the ALTER ANY LOGIN permission (ie the user can change any password for any user) then this works:

alter login mylogin with password = 'mylogin'

Otherwise, if you don't want to make every user in your system a superuser, add a parameter of the old password for the same command:

alter login mylogin with password = 'mylogin' old_password='oldpassword'
alter login mylogin with password = 'mylogin'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM