Skip to content

Commit 15f6b16

Browse files
authored
Update checksum-transact-sql.md
1 parent 2a10cda commit 15f6b16

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

docs/t-sql/functions/checksum-transact-sql.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,14 @@ An [expression](../../t-sql/language-elements/expressions-transact-sql.md) of an
5555
**int**
5656

5757
## 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.
5959

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`.
6162

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.
6364

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.
6566

6667
## Examples
6768
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
7071

7172
```sql
7273
-- Create a checksum index.
74+
7375
SET ARITHABORT ON;
7476
USE AdventureWorks2012;
7577
GO
@@ -86,6 +88,7 @@ This example shows the use of a checksum index as a hash index. This can help im
8688
/*Use the index in a SELECT query. Add a second search
8789
condition to catch stray cases where checksums match,
8890
but the values are not the same.*/
91+
8992
SELECT *
9093
FROM Production.Product
9194
WHERE CHECKSUM(N'Bearing Ball') = cs_Pname

0 commit comments

Comments
 (0)