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

前端 未结 3 1485
再見小時候
再見小時候 2021-02-18 14:12

Just what the title says, I need to change the password for an existing sql server login and I want to do it via sql script.

相关标签:
3条回答
  • 2021-02-18 14:21

    ALTER LOGIN

    http://msdn.microsoft.com/en-us/library/ms189828.aspx

    0 讨论(0)
  • 2021-02-18 14:29
    alter login mylogin with password = 'mylogin'
    
    0 讨论(0)
  • 2021-02-18 14:31

    If the user already has the ALTER ANY LOGIN permission (i.e. 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'
    
    0 讨论(0)
提交回复
热议问题