Operators in Expressions (Report Builder and SSRS)

 

Applies To: SQL Server 2016

An operator is a symbol that represents actions applied to one or more terms in an expression. The following categories of operators are supported in an expression: arithmetic, comparison, concatenation, logical or bitwise, and bit shift.

System_CAPS_ICON_note.jpg Note


You can create and modify paginated report definition (.rdl) files in Report Builder and in Report Designer in SQL Server Data Tools. Each authoring environment provides different ways to create, open, and save reports and related items.

Arithmetic

Arithmetic operators perform mathematical operations on two numeric terms in an expression.

OperatorDescription
^Raises a number to the power of another number.
*Multiplies two numbers.
/Divides two numbers and returns a floating-point result.
\Divides two numbers and returns an integer result.
ModReturns the integer remainder of a division. For example, 7 Mod 5 = 2 because the remainder of 7 divided by 5 is 2.
+Adds two numbers together.
-Returns the difference between two numbers or indicates the negative value of a numeric term.

Comparison

Comparison operators test whether two expressions are the same.

OperatorDescription
<Less than.
<=Less than or equal to.
>Greater than.
>=Greater than or equal to.
=Equal to.
<>Not equal to.
LikeDetermines whether a specific character string matches a specified pattern. A pattern can include regular characters and wildcard characters. During pattern matching, regular characters must exactly match the characters specified in the character string. However, wildcard characters can be matched with arbitrary fragments of the character string. Using wildcard characters makes the LIKE operator more flexible than using the = and != string comparison operators.

The following table lists characters that can be used as wildcards:

%: Any string of zero or more characters.

_: Any single character.

[ ]: Any single character within the specified range (for example, [a-f]) or set (for example, [aeiou]).

[^]: Any single character not within the specified range (for example, [^a-f]) or set (for example, [^aeiou])
IsCompares two object references.

String Concatenation

String concatenation appends the second string to the first string in an expression. For other string operations, use built-in functions.

OperatorDescription
&Concatenates two strings
+Concatenates two strings

Logical and Bitwise

Logical and bitwise operators perform logical manipulations between two integer terms in an expression.

OperatorDescription
AndPerforms a logical conjunction on two Boolean expressions, or bitwise conjunction on two numeric expressions.
NotPerforms logical negation on a Boolean expression, or bitwise negation on a numeric expression.
OrPerforms a logical disjunction on two Boolean expressions, or bitwise disjunction on two numeric values.
XorPerforms a logical exclusion operation on two Boolean expressions, or a bitwise exclusion on two numeric expressions.
AndAlsoPerforms logical conjunction on two expressions.
OrElsePerforms logical disjunction on two expressions.

Bit Shift

Bitwise operators perform bit manipulations between two integer terms in an expression.

OperatorDescription
<<Performs an arithmetic left-shift on a bit pattern.
>>Performs an arithmetic right-shift on a bit pattern.

Expression Dialog Box
Expressions (Report Builder and SSRS)
Expression Examples (Report Builder and SSRS)
Data Types in Expressions (Report Builder and SSRS)
Expression Dialog Box (Report Builder)

Community Additions

ADD
Show: