Hashbytes with different value when selecting and writing with update

Asked

Viewed 89 times

1

SELECT HASHBYTES('MD5','123') 

This select above returns me the following result: 0x202CB962AC59075B964B07152D234B70

But when I update the table using the same hashbytes

UPDATE USUARIOSLOGADOS SET TOKENSESSAO = HASHBYTES('MD5','123') WHERE CODIGOUSUARIO = 1

the value that is saved is this : ,¹b¬Y[–K-#Kp

It was to record the same result as the first example, but this is not how it happens... Does anyone know why ?

1 answer

1


I found out personally: The problem was that my datatype in the database was varchar. Performing some tests I saw that the correct type that the hashbytes returns is varbinary. made the change and worked right.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.