You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/t-sql/functions/checksum-transact-sql.md
+7-4Lines changed: 7 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -55,13 +55,14 @@ An [expression](../../t-sql/language-elements/expressions-transact-sql.md) of an
55
55
**int**
56
56
57
57
## Remarks
58
-
CHECKSUM computes a hash value, called the checksum, over its argument list. Use this hash value to build hash indexes. A hash index will result if the `CHECKSUM` function has column arguments, and an index is built over the computed CHECKSUM value. This can be used for equality searches over the columns.
58
+
`CHECKSUM` computes a hash value, called the checksum, over its argument list. Use this hash value to build hash indexes. A hash index will result if the `CHECKSUM` function has column arguments, and an index is built over the computed `CHECKSUM` value. This can be used for equality searches over the columns.
59
59
60
-
The `CHECKSUM` function satisfies hash function properties: `CHECKSUM` applied over any two lists of expressions will return the same value, if the corresponding elements of the two lists have the same data type, and if those corresponding elements have equality when compared using the equals (=) operator. Null values of a specified type are defined to compare as equal for `CHECKSUM` function purposes. If at least one of the values in the expression list changes, the list checksum will probably change. However, this is not guaranteed. Therefore, to detect whether values have changed, we recommend use of `CHECKSUM` only if your application can tolerate an occasional missed change. Otherwise, consider using [HashBytes](../../t-sql/functions/hashbytes-transact-sql.md) instead. With a specified MD5 hash algorithm, the probability that HashBytes will return the same result, for two different inputs, is much lower compared to CHECKSUM.
60
+
The `CHECKSUM` function satisfies hash function properties: `CHECKSUM` applied over any two lists of expressions will return the same value, if the corresponding elements of the two lists have the same data type, and if those corresponding elements have equality when compared using the equals (=) operator. Null values of a specified type are defined to compare as equal for `CHECKSUM` function purposes. If at least one of the values in the expression list changes, the list checksum will probably change. However, this is not guaranteed.
61
+
Therefore, to detect whether values have changed, we recommend use of `CHECKSUM` only if your application can tolerate an occasional missed change. Otherwise, consider using `HASHBYTES` instead. With a specified MD5 hash algorithm, the probability that `HASHBYTES` will return the same result, for two different inputs, is much lower compared to `CHECKSUM`.
61
62
62
-
The expression order affects the computed `CHECKSUM` value. The order of columns used for CHECKSUM(\*) is the order of columns specified in the table or view definition. This includes computed columns.
63
+
The expression order affects the computed `CHECKSUM` value. The order of columns used for `CHECKSUM(*)` is the order of columns specified in the table or view definition. This includes computed columns.
63
64
64
-
The CHECKSUM value depends on the collation. The same value stored with a different collation will return a different CHECKSUM value.
65
+
The `CHECKSUM` value depends on the collation. The same value stored with a different collation will return a different `CHECKSUM` value.
65
66
66
67
## Examples
67
68
These examples show the use of `CHECKSUM` to build hash indexes.
@@ -70,6 +71,7 @@ To build the hash index, the first example adds a computed checksum column to th
70
71
71
72
```sql
72
73
-- Create a checksum index.
74
+
73
75
SET ARITHABORT ON;
74
76
USE AdventureWorks2012;
75
77
GO
@@ -86,6 +88,7 @@ This example shows the use of a checksum index as a hash index. This can help im
86
88
/*Use the index in a SELECT query. Add a second search
87
89
condition to catch stray cases where checksums match,
0 commit comments