Mani
Mani

Reputation: 197

what is binary_checksum in SQL? and how does it work?

I am trying to understand binary_checksum and how it works in this scenario,

Value for a and b is its their ASCII values(97,98) but ab and ac is returning some other values (1650,1651).

The query is,

    select binary_checksum(7), id,binary_checksum('a'), binary_checksum('b'), 
binary_checksum('ab'), binary_checksum('ad') from employees;

How does it work ? Please explain.

Upvotes: 1

Views: 14674

Answers (1)

A_Sk
A_Sk

Reputation: 4630

BINARY_CHECKSUM usually used to detect changes in a row. If any row has any value changed, this function can be used to figure out if the values are changed in the rows. However, if the row is changed from A to B and once again changed back to A, the BINARY_CHECKSUM cannot be used to detect the changes.

Hope you already check this. binary_checksum

binary_checksum-and-working-example

Alternative to Binary_CheckSum :Using HASHBYTES() to compare columns

checksum-functions-in-sql-

Upvotes: 2

Related Questions