SQL Server->> Check functions CHECKSUM, Checksum_agg, Binary_checksum, and Hashbytes

Source: Internet
Author: User
Tags comparable

Today I looked specifically at what the school check functions under SQL Server are. Originally I just used a checksum in the work, and today I learned a little bit to find that there are other school check functions.

Here's a summary of what others have learned about the functions of the school tests under SQL Server, and take this opportunity to learn from others ' learning outcomes.

Http://bbs.51cto.com/thread-1145105-1.html

CHECKSUM and Binary_checksum
  • Checksum and Binary_checksum are both single-or multiple-column or expression-based values that can be generated for a row in a table with a data type of int.
  • The difference is that the binary_checksum is the calibration value that is generated after the binary is turned into binary.
  • Not all data types can be used on checksum or binary_checksum. BInary_checksum columns with an irreducible data type are ignored in the calculation.The non-comparable data types includeTextntextimage, cursor, xml  and non-comparable common language runtime (CLR) user-defined types.
  • MSDN mentions that binary_checksum can be used to detect changes in rows in a table. However, it is also mentioned that Binary_checksum (*) will return different values for most (but not all) row changes and can be used to detect most row modifications.
  • Because the value of the test is an int, according to the numerical distribution of int [ -2147483648,2147483647], if the number of rows in a long table is greater than 200 million The estimate will occur. This has come to you in previous work.
  • The differences between checksum and Binary_checksum are: 1) checksum is case insensitive. It thinks that Jerry and Jerry are the same school-checking values; 2) If two expressions have the same type and byte representation, the same value will be returned for Binary_checksum. For example, Binary_checksum for "2VOLVO director 20" and "3VOLVO director 30" will return the same value. This paragraph references the http://ultrasql.blog.51cto.com/9591438/1607407

Checksum_agg

This is an aggregation function.Returns the checksum for each value in the group.Null values are ignored. You can follow the over clause later. The Checksum_agg is used to detect changes in the table. If a value in the expression list changes, the checksum of the list is usually changed.  But in rare cases, the checksum remains the same. In many cases, this function should be used to detect whether the data in the table has changed or if the data for a field in the table has changed.

Hashbytes Returns the MD2, MD4, MD5, SHA, SHA1, or SHA2 hashes of its input in SQL Server. You can replace checksum or binary_checksum with MD5 to avoid duplication. However, performance may be degraded.

SQL Server->> Check functions CHECKSUM, Checksum_agg, Binary_checksum, and hashbytes

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.