Skip to content

Commit 035b580

Browse files
Merge pull request #34678 from MicrosoftDocs/main
Auto Publish – main to live - 2025-07-11 17:30 UTC
2 parents 8c3480e + 1995548 commit 035b580

2 files changed

Lines changed: 88 additions & 78 deletions

File tree

Lines changed: 83 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
---
2-
title: "BINARY_CHECKSUM (Transact-SQL)"
3-
description: "BINARY_CHECKSUM (Transact-SQL)"
2+
title: "BINARY_CHECKSUM (Transact-SQL)"
3+
description: BINARY_CHECKSUM returns the binary checksum value computed over a row of a table, or over a list of expressions.
44
author: markingmyname
55
ms.author: maghan
6-
ms.date: "07/24/2017"
6+
ms.reviewer: randolphwest
7+
ms.date: 07/06/2025
78
ms.service: sql
89
ms.subservice: t-sql
910
ms.topic: reference
@@ -15,85 +16,95 @@ helpviewer_keywords:
1516
- "binary [SQL Server], checksum values"
1617
dev_langs:
1718
- "TSQL"
18-
monikerRange: "= azuresqldb-current || = azure-sqldw-latest || >= sql-server-2016 || >= sql-server-linux-2017 || = azuresqldb-mi-current ||=fabric"
19+
monikerRange: "=azuresqldb-current || =azure-sqldw-latest || >=sql-server-2016 || >=sql-server-linux-2017 || =azuresqldb-mi-current || =fabric"
1920
---
20-
# BINARY_CHECKSUM (Transact-SQL)
21+
# BINARY_CHECKSUM (Transact-SQL)
22+
2123
[!INCLUDE [sql-asdb-asdbmi-asa-pdw-fabricse-fabricdw](../../includes/applies-to-version/sql-asdb-asdbmi-asa-fabricse-fabricdw.md)]
2224

2325
Returns the binary checksum value computed over a row of a table or over a list of expressions.
24-
26+
2527
:::image type="icon" source="../../includes/media/topic-link-icon.svg" border="false"::: [Transact-SQL syntax conventions](../../t-sql/language-elements/transact-sql-syntax-conventions-transact-sql.md)
26-
27-
## Syntax
28-
28+
29+
## Syntax
30+
2931
```syntaxsql
30-
BINARY_CHECKSUM ( * | expression [ ,...n ] )
31-
```
32-
32+
BINARY_CHECKSUM ( * | expression [ , ...n ] )
33+
```
34+
3335
> [!NOTE]
34-
> [!INCLUDE[synapse-analytics-od-unsupported-syntax](../../includes/synapse-analytics-od-unsupported-syntax.md)]
36+
> [!INCLUDE [synapse-analytics-od-unsupported-syntax](../../includes/synapse-analytics-od-unsupported-syntax.md)]
3537
3638
## Arguments
37-
*\**
38-
Specifies that the computation covers all the table columns. BINARY_CHECKSUM ignores columns of noncomparable data types in its computation. Noncomparable data types include
39-
* **cursor**
40-
* **image**
41-
* **ntext**
42-
* **text**
43-
* **xml**
44-
45-
and noncomparable common language runtime (CLR) user-defined types.
46-
47-
*expression*
48-
An [expression](../../t-sql/language-elements/expressions-transact-sql.md) of any type. BINARY_CHECKSUM ignores expressions of noncomparable data types in its computation.
49-
50-
## Return Types
51-
**int**
52-
53-
## Remarks
54-
`BINARY_CHECKSUM(*)`, computed on any row of a table, returns the same value as long the row isn't modified later. `BINARY_CHECKSUM` satisfies the properties of a hash function: when applied over any two lists of expressions, returns the same value if the corresponding elements of the two lists have the same type and are equal when compared using the equals (=) operator. For this definition, we say that null values, of a specified type, compare as equal values. If at least one of the values in the expression list changes, the expression checksum can also change. However, this change isn't guaranteed, and so to detect whether values have changed, we recommend use of `BINARY_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 than `BINARY_CHECKSUM`.
55-
39+
40+
#### _*_
41+
42+
Specifies that the computation covers all the table columns. `BINARY_CHECKSUM` ignores columns of noncomparable data types in its computation. Noncomparable data types include:
43+
44+
- **cursor**
45+
- **image**
46+
- **ntext**
47+
- **text**
48+
- **xml**
49+
- noncomparable common language runtime (CLR) user-defined types
50+
51+
#### _expression_
52+
53+
An [expression](../language-elements/expressions-transact-sql.md) of any type. `BINARY_CHECKSUM` ignores expressions of noncomparable data types in its computation.
54+
55+
## Return types
56+
57+
**int**
58+
59+
## Remarks
60+
61+
`BINARY_CHECKSUM(*)`, computed on any row of a table, returns the same value as long the row isn't modified later. `BINARY_CHECKSUM` satisfies the properties of a hash function: when applied over any two lists of expressions, it returns the same value if the corresponding elements of the two lists have the same type and are equal when compared using the equals (`=`) operator.
62+
63+
For this definition, we say that null values, of a specified type, compare as equal values. If at least one of the values in the expression list changes, the expression checksum can also change. However, this change isn't guaranteed, and so to detect whether values have changed, you should use `BINARY_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` returns the same result, for two different inputs, is much lower than `BINARY_CHECKSUM`.
64+
5665
`BINARY_CHECKSUM` can operate over a list of expressions, and it returns the same value for a specified list. `BINARY_CHECKSUM` applied over any two lists of expressions returns the same value if the corresponding elements of the two lists have the same type and byte representation. For this definition, null values of a specified type are considered to have the same byte representation.
57-
66+
5867
`BINARY_CHECKSUM` and `CHECKSUM` are similar functions. They can be used to compute a checksum value on a list of expressions, and the order of expressions affects the resultant value. The order of columns used for `BINARY_CHECKSUM(*)` is the order of columns specified in the table or view definition. This ordering includes computed columns.
59-
60-
`BINARY_CHECKSUM` and `CHECKSUM` return different values for the string data types, where locale can cause strings with different representation to compare as equal. The string data types are
61-
62-
* **char**
63-
* **nchar**
64-
* **nvarchar**
65-
* **varchar**
66-
67-
or
68-
69-
* **sql_variant** (if the base type of **sql_variant** is a string data type).
70-
71-
For example, the strings "McCavity" and "Mccavity" have different `BINARY_CHECKSUM` values. In contrast, for a case-insensitive server, `CHECKSUM` returns the same checksum values for those strings. You should avoid comparison of `CHECKSUM` values with `BINARY_CHECKSUM` values.
72-
73-
`BINARY_CHECKSUM` supports any length of type **varbinary(max)** and up to 255 characters of type **nvarchar(max)**.
74-
75-
## Examples
68+
69+
`BINARY_CHECKSUM` and `CHECKSUM` return different values for the string data types, where locale can cause strings with different representation to compare as equal. The string data types are:
70+
71+
- **char**
72+
- **nchar**
73+
- **nvarchar**
74+
- **varchar**
75+
- **sql_variant** (if the base type of **sql_variant** is a string data type)
76+
77+
For example, the strings `McCavity` and `Mccavity` have different `BINARY_CHECKSUM` values. In contrast, for a case-insensitive server, `CHECKSUM` returns the same checksum values for those strings. You should avoid comparison of `CHECKSUM` values with `BINARY_CHECKSUM` values.
78+
79+
`BINARY_CHECKSUM` supports any length of type **varbinary(max)**, and up to 255 characters of type **nvarchar(_n_)** / **nvarchar(max)**.
80+
81+
## Examples
82+
7683
This example uses `BINARY_CHECKSUM` to detect changes in a table row.
77-
84+
7885
```sql
79-
USE AdventureWorks2022;
80-
GO
81-
CREATE TABLE myTable (column1 INT, column2 VARCHAR(256));
82-
GO
83-
INSERT INTO myTable VALUES (1, 'test');
84-
GO
85-
SELECT BINARY_CHECKSUM(*) from myTable;
86-
GO
87-
UPDATE myTable set column2 = 'TEST';
88-
GO
89-
SELECT BINARY_CHECKSUM(*) from myTable;
90-
GO
91-
```
92-
93-
## See also
94-
[Aggregate Functions (Transact-SQL)](../../t-sql/functions/aggregate-functions-transact-sql.md)
95-
[CHECKSUM_AGG (Transact-SQL)](../../t-sql/functions/checksum-agg-transact-sql.md)
96-
[CHECKSUM (Transact-SQL)](../../t-sql/functions/checksum-transact-sql.md)
97-
[HASHBYTES (Transact-SQL)](../../t-sql/functions/hashbytes-transact-sql.md)
98-
99-
86+
USE AdventureWorks2022;
87+
GO
88+
89+
CREATE TABLE myTable (column1 INT, column2 VARCHAR (256));
90+
GO
91+
92+
INSERT INTO myTable VALUES (1, 'test');
93+
GO
94+
95+
SELECT BINARY_CHECKSUM(*) FROM myTable;
96+
GO
97+
98+
UPDATE myTable SET column2 = 'TEST';
99+
GO
100+
101+
SELECT BINARY_CHECKSUM(*) FROM myTable;
102+
GO
103+
```
104+
105+
## Related content
106+
107+
- [Aggregate Functions (Transact-SQL)](aggregate-functions-transact-sql.md)
108+
- [CHECKSUM_AGG (Transact-SQL)](checksum-agg-transact-sql.md)
109+
- [CHECKSUM (Transact-SQL)](checksum-transact-sql.md)
110+
- [HASHBYTES (Transact-SQL)](hashbytes-transact-sql.md)

docs/tools/overview-sql-tools.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ title: SQL Tools Overview
33
description: SQL query and management tools for SQL Server, Azure SQL (Azure SQL database, Azure SQL managed instance, SQL virtual machines), and Azure Synapse Analytics.
44
author: rwestMSFT
55
ms.author: randolphwest
6-
ms.reviewer: erinstellato
7-
ms.date: 06/13/2025
6+
ms.reviewer: erinstellato, iqrashaikh, mbarickman, drskwier, roblescarlos
7+
ms.date: 07/09/2025
88
ms.service: sql
99
ms.subservice: tools-other
1010
ms.topic: overview
@@ -43,10 +43,10 @@ The **database/application developer** writes Transact-SQL queries, debugs store
4343

4444
Recommended tools:
4545

46+
- **[MSSQL extension for Visual Studio Code](#mssql)**: Connect, manage database schemas, and run queries directly in Visual Studio Code
4647
- **[SQL Server Management Studio (SSMS)](#ssms)**: Create objects, run queries, and perform lightweight tasks
4748
- **[SQL Server Data Tools (SSDT)](#ssdt)** for Visual Studio: Schema and project-based development
4849
- **[.NET libraries](/azure/azure-sql/database/connect-query-dotnet-core)**: Programmatic access using libraries such as `Microsoft.Data.SqlClient`
49-
- **[Azure Data Studio](#ads)**: Lightweight scripting
5050

5151
### [Data analyst](#tab/analyst)
5252

@@ -55,7 +55,6 @@ The **data analyst** runs queries, and generates reports.
5555
- **[SQL Server Management Studio (SSMS)](#ssms)**: Run queries and perform lightweight tasks
5656
- **[sqlcmd](#sqlcmd)**: Lightweight CLI for automation
5757
- **[MSSQL extension for Visual Studio Code](#mssql)**: Lightweight tasks and scripting
58-
- **[Azure Data Studio](#ads)**: Queries and visualization
5958

6059
### [Data engineer](#tab/engineer)
6160

@@ -72,7 +71,7 @@ The following table lists available tools and extensions.
7271

7372
| Tool | Description | Operating system | Feedback |
7473
| --- | --- | --- | --- |
75-
| **Graphical tools** | | | |
74+
| **Graphical tools** | | | |
7675
| <a id="ssms"></a> **[SQL Server Management Studio (SSMS)](../ssms/download-sql-server-management-studio-ssms.md)** | Manage SQL Server and Azure SQL databases with full GUI support. Access, configure, manage, administer, and develop all components of the SQL Database Engine on-premises and the cloud, including Azure Synapse Analytics and SQL database for Microsoft Fabric. SSMS is a comprehensive application that combines a broad group of graphical tools and a rich script editor to provide access to SQL for database administrators and developers of all skill levels. | Windows only | [Feedback](https://aka.ms/ssms-feedback) |
7776
| <a id="ssdt"></a> **[SQL Server Data Tools (SSDT)](../ssdt/download-sql-server-data-tools-ssdt.md)** | A modern development tool for building SQL Server relational databases, Azure SQL databases, Analysis Services (AS) data models, Integration Services (IS) packages, and Reporting Services (RS) reports. With SQL Server Data tools (SSDT), you can design and deploy any SQL Server content type with the same ease as you would develop an application in **[Visual Studio](https://visualstudio.microsoft.com/downloads/)**. | Windows only | [Feedback](https://aka.ms/vs-feedback) |
7877
| <a id="mssql"></a> **[MSSQL extension for Visual Studio Code](visual-studio-code-extensions/mssql/mssql-extension-visual-studio-code.md)** | The official SQL Server extension that supports connections to SQL Server and Azure SQL, and a rich editing experience for Transact-SQL (T-SQL). Write T-SQL scripts in a lightweight editor. | Windows, macOS, Linux | [Feedback](https://github.com/microsoft/vscode-mssql) |
@@ -96,7 +95,7 @@ These tools are available for Windows only.
9695
| --- | --- |
9796
| <a id="sscm"></a> **[SQL Server Configuration Manager](configuration-manager/sql-server-configuration-manager-help.md)** | Use SQL Server Configuration Manager to configure SQL Server services and configure network connectivity. |
9897
| <a id="dreplay"></a> **[Distributed Replay](distributed-replay/install-distributed-replay.md)** <sup>1</sup> | Use the Distributed Replay feature to help you assess the impact of future SQL Server upgrades. Also use Distributed Replay to help assess the impact of hardware and operating system upgrades, and SQL Server tuning. |
99-
| <a id="ssbdiagnose"></a> **[ssbdiagnose](ssbdiagnose/ssbdiagnose-utility-service-broker.md)** |**ssbdiagnose** reports issues in Service Broker conversations or the configuration of Service Broker services. |
98+
| <a id="ssbdiagnose"></a> **[ssbdiagnose](ssbdiagnose/ssbdiagnose-utility-service-broker.md)** | **ssbdiagnose** reports issues in Service Broker conversations or the configuration of Service Broker services. |
10099
| <a id="ssma"></a> **[SQL Server Migration Assistant (SSMA)](../ssma/sql-server-migration-assistant.md)** | Use SQL Server Migration Assistant to automate database migration to SQL Server and Azure SQL from Microsoft Access, Db2, MySQL, Oracle, and Sybase. |
101100

102101
<sup>1</sup> Distributed Replay is supported on [!INCLUDE [sssql16-md](../includes/sssql16-md.md)] through [!INCLUDE [sssql19-md](../includes/sssql19-md.md)] only.

0 commit comments

Comments
 (0)