Data table: people_t
Columns:
Username - nvarchar(200)
PasswordHash - nvarchar(1000)
Query:
I want to change multiple passwords of type hash to be the usernames. After the command, the passwords should still be hashed but the actual password will be the user's username. E.g.
Will become:
I am trying the following:
DECLARE @UserPass SHA1 --Var for storage of username
SET @UserPass=UserName --Add current Username's to UserPass var
UPDATE people_t --Update the people_t
SET PasswordHash=@UserPass --Do the job
Do I even need a WHERE clause or what am I doing wrong here?
Thanks in advance folks.
I think what you might want (for sql server) is this:
update people_t set passwordhash = HASHBYTES('SHA1', username)
Your pseudo code seems to set a single hash (which would be based on one username) and then is updating all people with that single username.
Not sure what the SHA1 type is in your code above - don't recognize that.