Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Update all rows by looping via cursor

Author  Topic 

cplusplus
Aged Yak Warrior

567 Posts

Posted - 2007-08-21 : 15:23:37
How can i loop through every row from table tab_users, updating the field Hashpassword , using the same rows another column password field. hash the content and update to hashpassword column.

i want to get all the userid , password from table tab_users to a cursor and fetch one row by another and use the following with MD5 for column Hashpassword field.


i used the following, which works but it works for 1 row at a time and it is manual.
*********************************************************************************************
Declare @HashIt varchar(50)

select @HashIt = 'pacopass'
Update tab_users set Hashpassword = HashBytes('MD5', @HashIt) where userid = 1

Thank you very much for the help.

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-08-21 : 15:53:07
Update tab_users set Hashpassword = HashBytes('MD5', password)

maybe??



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

cplusplus
Aged Yak Warrior

567 Posts

Posted - 2007-08-21 : 22:08:26
It did'nt work..
Thank you.

quote:
Originally posted by Peso

Update tab_users set Hashpassword = HashBytes('MD5', password)

maybe??



E 12°55'05.25"
N 56°04'39.16"

Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-08-21 : 22:15:00
quote:
It did'nt work..

Any error ? Rows not updated ? please explain


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -