Adaptive Server Hashbytes Null Handling

The Adaptive Server Transact-SQL® hashbytes function ignores null values.

For example, if a source table has column_a=34 and column_b=NULL and a target table has column_a=NULL and column_b=34, the equality test is:

hashbytes(34, NULL) = hashbytes(NULL, 34),

which computes as:

hashbytes(34) = hashbytes(34), (a “false positive” match).

To manage the Adaptive Server hashbytes limitation, DA server provides a configuration parameter, db_hash_ase_ignore_null, to help reduce the chances of a “false positive” row match. Setting db_hash_ase_ignore_null to false eliminates this issue by adding an extra value to denote the “is null” state of a column. The above example becomes:

hashbytes(0, 34, 1, NULL) = hashbytes(1, NULL, 0, 34),

which computes as:

hashbytes(0, 34, 1) = hashbytes(1, 0, 34).