'Changing a user password in Microsoft SQL Server Management Studio

What is the best way to change a user password (in a table) in Microsoft SQL Server Management Studio (see image example)?

I know you can run a query, but I am not sure how to. Also, can you actually create an MD5hash generated password and paste/enter it into the password field?

enter image description here



Solution 1:[1]

Assuming a user is unique, just search for that username in a WHERE clause. You can use the HashBytes function to generate the MD5 hash:

SELECT HashBytes('MD5', 'stringToHashGoesHere')

You can then insert that into the MD5 column

Solution 2:[2]

You need to update password field of specific userid. It is hard to see your actual table and column names so I just substituted with generic names. Please note that HASHBYTES will return VARBINARY value.

DECLARE @MyPassword VARBINARY(250) = HASHBYTES('MD5','MyNewPassword')
UPDATE MyTable
SET PasswordField = @MyPassword
Where UserId = 'MyUser'

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 TTeeple
Solution 2