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
@@ -51,42 +53,41 @@ The number of bits by which *expression_value* should be shifted. *shift_amount*
51
53
52
54
Returns the same type as *expression_value*.
53
55
54
-
The *shift_amount* parameter is cast to a **bigint**. The parameter can be positive or negative, and can also be greater than the number of bits in the datatype of *expression_value*. When *shift_amount* is negative, the shift operates in the opposite direction. For example, `LEFT_SHIFT (expr, -1)` is the same as `RIGHT_SHIFT (expr, 1)`. When *shift_amount* is greater than the number of bits in *expression_value*, the result returned will be`0`.
56
+
The *shift_amount* parameter is cast to a **bigint**. The parameter can be positive or negative, and can also be greater than the number of bits in the data type of *expression_value*. When *shift_amount* is negative, the shift operates in the opposite direction. For example, `LEFT_SHIFT (expr, -1)` is the same as `RIGHT_SHIFT (expr, 1)`. When *shift_amount* is greater than the number of bits in *expression_value*, the result returned is`0`.
55
57
56
-
LEFT_SHIFT performs a logical shift. After bits are shifted, any vacant positions will be filled by `0`, regardless of whether the original value was positive or negative.
58
+
`LEFT_SHIFT` performs a logical shift. After bits are shifted, any vacant positions are filled by `0`, regardless of whether the original value was positive or negative.
57
59
58
60
## Remarks
59
61
60
-
In the initial implementation, Distributed Query functionality for the bit manipulation functions within linked server or ad hoc queries (OPENQUERY) won't be supported.
62
+
In the initial implementation, Distributed Query functionality for the bit manipulation functions within linked server or ad hoc queries (`OPENQUERY`) isn't supported.
61
63
62
-
The `<<` method for the `LEFT_SHIFT` function is not currently supported in [!INCLUDE [fabric](../../includes/fabric.md)].
64
+
The `<<` method for the `LEFT_SHIFT` function isn't currently supported in [!INCLUDE [fabric](../../includes/fabric.md)].
63
65
64
66
## Examples
65
67
66
-
In the following example, the integer value 12345 is left-shifted by 5 bits.
68
+
In the following example, the integer value 12,345 is left-shifted by 5 bits.
67
69
68
70
```sql
69
71
SELECT LEFT_SHIFT(12345, 5);
70
72
```
71
73
72
-
The result is 395040. If you convert 12345 to binary, you have `0011 0000 0011 1001`. Shifting this to the left by 5 becomes `0110 0000 0111 0010 0000`, which is `395040` in decimal.
74
+
The result is 395,040. If you convert 12,345 to binary, you have `0011 0000 0011 1001`. Shifting this value to the left by 5 bits becomes `0110 0000 0111 0010 0000`, which is `395040` in decimal.
73
75
74
76
The following table demonstrates what happens during each shift.
75
77
76
-
|Integer value|Binary value|Description|
77
-
|---:|---:|---|
78
-
|12345|`0011 0000 0011 1001`|Starting value|
79
-
|24690|`0110 0000 0111 0010`|Shift left by 1|
80
-
|49380|`1100 0000 1110 0100`|Shift left by 2|
81
-
|98760|`0001 1000 0001 1100 1000`|Shift left by 3,<br/>and open into a new byte|
82
-
|197520|`0011 0000 0011 1001 0000`|Shift left by 4|
83
-
|395040|`0110 0000 0111 0010 0000`|Shift left by 5|
78
+
|Integer value|Binary value|Description|
79
+
|---:|---:|---|
80
+
|`12345`|`0011 0000 0011 1001`|Starting value|
81
+
|`24690`|`0110 0000 0111 0010`|Shift left by 1|
82
+
|`49380`|`1100 0000 1110 0100`|Shift left by 2|
83
+
|`98760`|`0001 1000 0001 1100 1000`|Shift left by 3,and open into a new byte|
84
+
|`197520`|`0011 0000 0011 1001 0000`|Shift left by 4|
85
+
|`395040`|`0110 0000 0111 0010 0000`|Shift left by 5|
@@ -51,42 +53,41 @@ The number of bits by which *expression_value* should be shifted. *shift_amount*
51
53
52
54
Returns the same type as *expression_value*.
53
55
54
-
The *shift_amount* parameter is cast to a **bigint**. The parameter can be positive or negative, and can also be greater than the number of bits in the datatype of *expression_value*. When *shift_amount* is negative, the shift operates in the opposite direction. For example, `LEFT_SHIFT (expr, -1)` is the same as `RIGHT_SHIFT (expr, 1)`. When *shift_amount* is greater than the number of bits in *expression_value*, the result returned will be`0`.
56
+
The *shift_amount* parameter is cast to a **bigint**. The parameter can be positive or negative, and can also be greater than the number of bits in the data type of *expression_value*. When *shift_amount* is negative, the shift operates in the opposite direction. For example, `LEFT_SHIFT (expr, -1)` is the same as `RIGHT_SHIFT (expr, 1)`. When *shift_amount* is greater than the number of bits in *expression_value*, the result returned is`0`.
55
57
56
-
RIGHT_SHIFT performs a logical shift. After bits are shifted, any vacant positions will be filled by `0`, regardless of whether the original value was positive or negative.
58
+
`RIGHT_SHIFT` performs a logical shift. After bits are shifted, any vacant positions are filled by `0`, regardless of whether the original value was positive or negative.
57
59
58
60
## Remarks
59
61
60
-
In the initial implementation, Distributed Query functionality for the bit manipulation functions within linked server or ad hoc queries (OPENQUERY) won't be supported.
62
+
In the initial implementation, Distributed Query functionality for the bit manipulation functions within linked server or ad hoc queries (`OPENQUERY`) aren't supported.
61
63
62
-
The `>>` method for the `RIGHT_SHIFT` function is not currently supported in [!INCLUDE [fabric](../../includes/fabric.md)].
64
+
The `>>` method for the `RIGHT_SHIFT` function isn't currently supported in [!INCLUDE [fabric](../../includes/fabric.md)].
63
65
64
66
## Examples
65
67
66
-
In the following example, the integer value 12345 is right-shifted by 5 bits.
68
+
In the following example, the integer value 12,345 is right-shifted by 5 bits.
67
69
68
70
```sql
69
71
SELECT RIGHT_SHIFT(12345, 5);
70
72
```
71
73
72
-
The result is 385. If you convert 12345 to binary, you have `0011 0000 0011 1001`. Shifting this to the right by 5 becomes `0001 1000 0001`, which is `385` in decimal.
74
+
The result is 385. If you convert 12,345 to binary, you have `0011 0000 0011 1001`. Shifting this value to the right by 5 bits becomes `0001 1000 0001`, which is `385` in decimal.
73
75
74
76
The following table demonstrates what happens during each shift.
description: Logical operators test for the truth of some condition.
4
4
author: rwestMSFT
5
5
ms.author: randolphwest
6
-
ms.date: "03/06/2017"
6
+
ms.date: 01/29/2026
7
7
ms.service: sql
8
8
ms.subservice: t-sql
9
9
ms.topic: reference
@@ -17,25 +17,25 @@ helpviewer_keywords:
17
17
dev_langs:
18
18
- "TSQL"
19
19
---
20
-
# Logical Operators (Transact-SQL)
20
+
# Logical operators (Transact-SQL)
21
+
21
22
[!INCLUDE [SQL Server Azure SQL Managed Instance](../../includes/applies-to-version/sql-asdbmi.md)]
22
23
23
-
Logical operators test for the truth of some condition. Logical operators, like comparison operators, return a **Boolean** data type with a value of TRUE, FALSE, or UNKNOWN.
24
-
25
-
|Operator|Meaning|
26
-
|--------------|-------------|
27
-
|[ALL](../../t-sql/language-elements/all-transact-sql.md)|TRUE if all of a set of comparisons are TRUE.|
28
-
|[AND](../../t-sql/language-elements/and-transact-sql.md)|TRUE if both Boolean expressions are TRUE.|
29
-
|[ANY](../../t-sql/language-elements/any-transact-sql.md)|TRUE if any one of a set of comparisons are TRUE.|
30
-
|[BETWEEN](../../t-sql/language-elements/between-transact-sql.md)|TRUE if the operand is within a range.|
31
-
|[EXISTS](../../t-sql/language-elements/exists-transact-sql.md)|TRUE if a subquery contains any rows.|
32
-
|[IN](../../t-sql/language-elements/in-transact-sql.md)|TRUE if the operand is equal to one of a list of expressions.|
33
-
|[LIKE](../../t-sql/language-elements/like-transact-sql.md)|TRUE if the operand matches a pattern.|
34
-
|[NOT](../../t-sql/language-elements/not-transact-sql.md)|Reverses the value of any other Boolean operator.|
35
-
|[OR](../../t-sql/language-elements/or-transact-sql.md)|TRUE if either Boolean expression is TRUE.|
36
-
|[SOME](../../t-sql/language-elements/some-any-transact-sql.md)|TRUE if some of a set of comparisons are TRUE.|
Logical operators test for the truth of some condition. Logical operators, like comparison operators, return a **Boolean** data type with a value of `TRUE`, `FALSE`, or `UNKNOWN`.
25
+
26
+
| Operator | Meaning |
27
+
| --- | --- |
28
+
|[ALL](all-transact-sql.md)|`TRUE` if all of a set of comparisons are `TRUE`. |
29
+
|[AND](and-transact-sql.md)|`TRUE` if both Boolean expressions are `TRUE`. |
30
+
|[ANY](any-transact-sql.md)|`TRUE` if any one of a set of comparisons are `TRUE`. |
31
+
|[BETWEEN](between-transact-sql.md)|`TRUE` if the operand is within a range. |
32
+
|[EXISTS](exists-transact-sql.md)|`TRUE` if a subquery contains any rows. |
33
+
|[IN](in-transact-sql.md)|`TRUE` if the operand is equal to one of a list of expressions. |
34
+
|[LIKE](like-transact-sql.md)|`TRUE` if the operand matches a pattern. |
35
+
|[NOT](not-transact-sql.md)| Reverses the value of any other Boolean operator. |
36
+
|[OR](or-transact-sql.md)|`TRUE` if either Boolean expression is `TRUE`. |
37
+
|[SOME | ANY](some-any-transact-sql.md)|`TRUE` if some of a set of comparisons are `TRUE`. |
0 commit comments