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.
| Author |
Topic |
|
stegothdump
Starting Member
9 Posts |
Posted - 2012-01-16 : 10:34:33
|
| Hey There,I've written the following SQL query DECLARE @HashThis NVARCHAR(MAX)DECLARE @NewPassword NVARCHAR(MAX)DECLARE @Salt NVARCHAR(MAX)EXEC dbo.sp_GenerateRandomString 8, @salt OUTPUTSELECT @HashThis = Password FROM RegisteredUsersSELECT @NewPassword = SUBSTRING(UPPER(master.dbo.fn_varbintohexstr(HASHBYTES('SHA1', @HashThis + @Salt))),3,20)UPDATE RegisteredUsersSET NopPassword = @NewPassword, PasswordSalt = @SaltIts doing what I want but it look like the first password in the table row is being used for all the rows, do i need to loop this in some way?Many thanks,S |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-01-16 : 10:47:00
|
| [code]DECLARE @Salt NVARCHAR(MAX)EXEC dbo.sp_GenerateRandomString 8, @salt OUTPUTUPDATE RegisteredUsersSET NopPassword =SUBSTRING(UPPER(master.dbo.fn_varbintohexstr(HASHBYTES('SHA1', Password + @Salt))),3,20),, PasswordSalt = @Salt[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
stegothdump
Starting Member
9 Posts |
Posted - 2012-01-16 : 11:05:12
|
| Hey visakh16,Thanks for the quick reply, that has sorted my password col but the salt looks like it is the same...is there a way to run sp_GenerateRandomString for each row?Many thanks,S |
 |
|
|
|
|
|
|
|