You should also not use CAST
for getting the text of a hash algorithm. CAST(HASHBYTES('...') AS VARCHAR(32))
is not the same as CONVERT(VARCHAR(32), HASHBYTES('...'), 2)
. Without the last parameter, the result would be the same, but not a readable text. As far as I know, You cannot specify that last parameter in CAST
.