Checksum comparing two table field value differences

Source: Internet
Author: User
Tags comparable

CHECKSUM

Returns a checksum value that is computed on the row of a table or on an expression list. The CHECKSUM is used to generate a hash index.

Grammar

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

Parameters

*

Specifies that calculations are made on all columns of the table. If either column is a non-comparable data type, CHECKSUM returns an error. The non-comparable data type is the text,ntext,image,cursor , and sql_variantof one of the first 4 data types in the base type.

Expression

Is any type of expression other than the one that is comparable to the data type.

return type

Int

Comments

CHECKSUM calculates a hash value, called a checksum, on its argument list. This hash value is used to generate a hash index. If the CHECKSUM parameter is a column and the index is generated on the computed CHECKSUM value, the result is a hash index that can be used for equivalent searches on the column.

CHECKSUM satisfies the following properties of the hash function: When using the equals (=) operator comparison, if the corresponding elements of the two list have the same type and are equal, the CHECKSUM applied on any two expression lists will return the same value. The purpose of this definition is to: a NULL value of a given type is compared as "equal". If a value in the expression list changes, the checksum value of the list usually changes. However, in rare cases, the checksum will remain unchanged.

Binary_checksum and CHECKSUM have similar functionality: they can be used to calculate checksum values on an expression list, and the order of the expressions affects the resulting values. The column order used in CHECKSUM (*) is the column order specified in the table or view definition, including computed columns.

CHECKSUM and binary_checksum only return different values for string data types, which can cause strings with different representations to be compared in an equivalent way. The string data type is char,varchar,nchar,nvarchar , or sql_variant(if its base type is a string data type). For example, the Binary_checksum values for the string "McCavity" and "mccavity" are different. Conversely, in a case-insensitive server, the CHECKSUM of the above string returns the same checksum value. The CHECKSUM value should not be compared to the binary_checksum value.

Checksum comparing two table field value differences

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.