Posts

BINARY_CHECKSUM - different result depending on number of rows

Image
9 1 I wonder why the BINARY_CHECKSUM function returns different result for the same: SELECT *, BINARY_CHECKSUM(a,b) AS bc FROM (VALUES(1, NULL, 100), (2, NULL, NULL), (3, 1, 2)) s(id,a,b); SELECT *, BINARY_CHECKSUM(a,b) AS bc FROM (VALUES(1, NULL, 100), (2, NULL, NULL)) s(id,a,b); Ouput: +-----+----+------+-------------+ | id | a | b | bc | +-----+----+------+-------------+ | 1 | | 100 | -109 | | 2 | | | -2147483640 | | 3 | 1 | 2 | 18 | +-----+----+------+-------------+ -- -109 vs 100 +-----+----+------+------------+ | id | a | b | bc | +-----+----+------+------------+ | 1 | | 100 | 100 | | 2 | | | 2147483647 | +-----+----+------+------------+ And for second sample I...