wta306 (4/25/2011)
How do you determine what size to make your VARBINARY field to hold the results of the HASHBYTES function?Is it simply a matter of setting it to be equal to the largest HashByte function input value?
DECLARE @vHashResults AS VARBINARY(40)
DECLARE @vHashInput01 AS CHAR(20)
DECLARE @vHashInput02 AS CHAR(20)
SET @vHashInput01 = 'thisisa20bytechar123'
SET @vHashInput02 = 'thisisa21bytechar1234'
SET @vHashResults = HashBytes('SHA1', @vHashInput01 + @vHashInput02)
I would be somewhat horrified if HashBytes('SHA1', <anything>) delived a result with any length other than 160 bits (20 bytes)! That's what MS thinks it delivers too, according to BoL.
Tom