Using (and moving to) raw data types for hash keys

Roelant Vos

Roelant Vos

Roelant Vos

You may also like...

2 Responses

  1. zsombor zsombor says:

    I like this approach a lot Roelant using binary type. I do it similarly, I do the hash computation in the schema of the staging table, as non persisted computed column for both the keys and the diffs. It is easier to manage than in the ETL.

    My key formula looks like this:
    HashDiff AS CAST(
    HASHBYTES(‘SHA1’,
    COALESCE(CAST(Colum1 AS VARBINARY(4)), 0x0) + 0x00
    + COALESCE(CAST(Column2 AS VARBINARY(3)), 0x0) + 0x00
    ) AS BINARY(20))

     

Leave a Reply