Returns the MD2, MD4, MD5, SHA, SHA1, or SHA2 hash of its input.


HASHBYTES ( '<algorithm>', { @input | 'input' } )

<algorithm>::= MD5 | SHA | SHA1 | SHA2_256 | SHA2_512



Identifies the hashing algorithm to be used to hash the input. This is a required argument with no default. The single quotation marks are required. Note that deprecated algorithms MD2 and MD4 supported by SQL Server are not supported by Querona.


Specifies a variable containing the data to be hashed. @input is varchar, nvarchar, or varbinary.


Specifies an expression that evaluates to a character or binary string to be hashed.

The output conforms to the algorithm standard: 128 bits (16 bytes) for MD2, MD4, and MD5; 160 bits (20 bytes) for SHA and SHA1; 256 bits (32 bytes) for SHA2_256, and 512 bits (64 bytes) for SHA2_512.

Return types

varbinary (maximum 2000 bytes)

The length of return varbinary value differes from the original MS SQL Server implementation of 8000 bytes due to compatibility reasons with other database engines like Oracle.


SELECT HASHBYTES('SHA2_256', 0x4234123412341234);

See Also