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/data-types/binary-and-varbinary-transact-sql.md
+10-14Lines changed: 10 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,10 @@
1
1
---
2
-
title: "binary and varbinary (Transact-SQL)"
2
+
title: "Binary and Varbinary (Transact-SQL)"
3
3
description: "Binary data types of either fixed length or variable length."
4
4
author: MikeRayMSFT
5
5
ms.author: mikeray
6
-
ms.reviewer: randolphwest
7
-
ms.date: 09/24/2024
6
+
ms.reviewer: randolphwest, jovanpop
7
+
ms.date: 11/20/2025
8
8
ms.service: sql
9
9
ms.subservice: t-sql
10
10
ms.topic: "reference"
@@ -67,7 +67,7 @@ When other data types are converted to **binary** or **varbinary**, the data is
67
67
68
68
Converting data to the **binary** and **varbinary** data types is useful if **binary** data is the easiest way to move around data. At some point, you might convert a value type to a binary value of large enough size and then convert it back. This conversion always results in the same value if both conversions are taking place on the same version of [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)]. The binary representation of a value might change from version to version of [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)].
69
69
70
-
You can convert **int**, **smallint**, and **tinyint** to **binary** or **varbinary**. If you convert the **binary** value back to an integer value, this value will be different from the original integer value if truncation has occurred. For example, the following SELECT statement shows that the integer value `123456` is stored as a binary `0x0001e240`:
70
+
You can convert **int**, **smallint**, and **tinyint** to **binary** or **varbinary**. If you convert the **binary** value back to an integer value, this value is different from the original integer value if truncation occurred. For example, the following SELECT statement shows that the integer value `123456` is stored as a binary `0x0001e240`:
71
71
72
72
```sql
73
73
SELECT CAST( 123456AS BINARY(4) );
@@ -83,10 +83,10 @@ The following batch shows that this silent truncation can affect arithmetic oper
83
83
84
84
```sql
85
85
DECLARE @BinaryVariable2 BINARY(2);
86
-
86
+
87
87
SET @BinaryVariable2 =123456;
88
88
SET @BinaryVariable2 = @BinaryVariable2 +1;
89
-
89
+
90
90
SELECT CAST( @BinaryVariable2 ASINT);
91
91
GO
92
92
```
@@ -96,12 +96,8 @@ The final result is `57921`, not `123457`.
96
96
> [!NOTE]
97
97
> Conversions between any data type and the **binary** data types are not guaranteed to be the same between versions of [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)].
98
98
99
-
## Limitations
100
-
101
-
Currently, in [!INCLUDE [fabric](../../includes/fabric.md)], only varbinary(*n*) is supported. The binary and varbinary(max) data types are not supported.
102
-
103
-
## See also
99
+
## Related content
104
100
105
-
-[CAST and CONVERT (Transact-SQL)](../../t-sql/functions/cast-and-convert-transact-sql.md)
106
-
-[Data Type Conversion (Database Engine)](../../t-sql/data-types/data-type-conversion-database-engine.md)
0 commit comments