Logo 
Search:

SQL Server Articles

Submit Article
Home » Articles » SQL Server » Aggregate FunctionsRSS Feeds

BINARY_CHECKSUM Function

Posted By: Sarita Patel     Category: SQL Server     Views: 3858

This article explains BINARY_CHECKSUM function of sql server with different examples.

BINARY_CHECKSUM function is used to detect changes to a row of a table. It returns the binary checksum value computed for row of a table or list of expressions.

BINARY_CHECKSUM function ignores noncomparable  data types in its computation. Noncomparable data types are text, ntext, image, and cursor, sql_variant with any of the above types as its base type.

BINARY_CHECKSUM(*) computed on any row of a table returns the same value as long the row is not subsequently modified. 

Note that the order of expressions affects the resultant value. 

 


Syntax of BINARY_CHECKSUM function :

BINARY_CHECKSUM ( * | expression [ ,...n ] )


 means that the computation is over all the columns of the table.

Expression is any valid sql expression of any type. BINARY_CHECKSUM ignores expressions of noncomparable data types in its computation.




Example of BINARY_CHECKSUM function :

Example 1 : Use of BINARY_CHECKSUM function to detect changes in the row of a table in SELECT clause

SELECT ProductID, BINARY_CHECKSUM(*) AS 'Binary Checksum'

FROM   Products 

 

Output

ProductID           Binary Checksum

      1                        739373310

      2                        1240574164

      3                       -1469771421

      4                        1424280107

      5                        192100513

 

Above example displays checksum of rows modified in the products table.

  
Share: 

 
 
 

Didn't find what you were looking for? Find more on BINARY_CHECKSUM Function Or get search suggestion and latest updates.

Sarita Patel
Sarita Patel author of BINARY_CHECKSUM Function is from United States.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!