SQL SERVER – Change Password at the First Login

Just like many other databases and applications, SQL Server also supports the feature to change password at the first login. Let us see the script of how we can do it.

SQL SERVER - Change Password at the First Login changepassword-800x394

Here is the script:

CREATE LOGIN LoginName
WITH PASSWORD = 'VeryStrongPassword'
MUST_CHANGE, CHECK_EXPIRATION = ON;

When you run the script above, it will create a new login and set the new password policy. If we create the login with password – MUST_CHANGE, whenever the user logs in the first time, the user will have to change the password.

One should also remember that if you say the password must change, you should also set CHECK_EXPIRATION as ON, otherwise it will not work.

Well, that’s it for today. I hope you like the blog post and leave a comment.

Let me know if you are interested to know more about this topic and I will write more blogs as well as create an SQL in Sixty Seconds video.

Here are my few recent videos and I would like to know what is your feedback about them.

Reference: Pinal Dave (http://blog.SQLAuthority.com)

, SQL Scripts, SQL Server, SQL Server Security
Previous Post
SQL SERVER – AdHoc Queries and Optimize for Adhoc Workloads
Next Post
Install Python3 on Linux

Related Posts

1 Comment. Leave new

  • Hi Pinal,
    That’s for the post.
    I’m trying to think how this would fit in with SQL Servers at work. We use AD for authentication for user accounts which tend to be admins and server authentication for systems.
    What would be a good use case?
    I like your posts as it makes me think about areas of the SQL I haven’t thought about.
    Regards,
    David Tovee

    Reply

Leave a Reply