Link to home
Start Free TrialLog in
Avatar of fjkilken
fjkilken

asked on

BINARY_CHECKSUM is not yielding expected value.

BINARY_CHECKSUM is not yielding expected value. 

I have 2 tables with 20 columns in each. 

16 of these columns have the same value and 4 do not, yet when I use BINARY_CHECKSUM it gives the same value.

Below is the data table.

Why are the checksum values not unique?

What alternative do I have to using BINARY_CHECKSUM ?

thanks!


SELECT BINARY_CHECKSUM(*) FROM #stg      --   -1571139392
SELECT BINARY_CHECKSUM(*) FROM #facts   --   -1571139392


 

source#facts#stg
dim_receipt_date_id-120210308
dim_dock_date_id-120210308
dim_min_dock_date_id-120210308
dim_max_dock_date_id-120210308
fact_idRMA3649121-1RMA3649121-1
order_nbrRMA3649121RMA3649121
line_nbr11
dim_order_date_id2021021720210217
dim_call_date_id2021021720210217
dim_disposition_date_id-1-1
dim_disposition_id33
dim_ship_date_id-1-1
dim_credit_date_id2021030820210308
dim_carrier_notify_date_id-1-1
dim_carrier_delivery_date_id-1-1
dim_carrier_collection_date_id-1-1
dim_carrier_expected_collection_date_id-1-1
dim_country_id2828
dim_site_id735735
dim_service_type_id4949
Avatar of fjkilken
fjkilken

ASKER

I found using HASHBYTES('SHA2_256', .. I will get a unique value but that will mean an update of a huge amount of rows in my tables and significant code change so I'd prefer not go that route if possible.
SELECT HASHBYTES
('SHA2_256',
      CAST( CONCAT(
      fact_id,
      order_nbr,
      line_nbr,
      dim_order_date_id,
      dim_call_date_id,
      dim_disposition_date_id,
      dim_disposition_id,
      dim_receipt_date_id,
      dim_dock_date_id,
      dim_ship_date_id,
      dim_credit_date_id,
      dim_carrier_notify_date_id,
      dim_carrier_delivery_date_id,
      dim_carrier_collection_date_id,
      dim_carrier_expected_collection_date_id,
      dim_min_dock_date_id,
      dim_max_dock_date_id,
      dim_country_id,
      dim_site_id,
      dim_service_type_id
      ) AS VARCHAR(MAX) )
) from #facts  


--Result>>
from #stg      --   0x95B73644AFA7D6E3DD91D3CB3774F0D828B102676A94818F6A718C0CA5CF82BD
from #facts      --   0x52B8DB837F549278305E7BC5FAC1E4BD6CF8822BFC70761403572A978299B1C0 
ASKER CERTIFIED SOLUTION
Avatar of Scott Pletcher
Scott Pletcher
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial