T-SQL Tutorial

T-SQL Operators


SQL Server supports several types of operators that can be used to filter or manipulate data in a database:

Relational operators: These operators are used to compare values in a database and return a Boolean value (true or false) based on the outcome of the comparison. Examples of relational operators include = (equal to), > (greater than), and <> (not equal to).

Compound operators: These operators combine multiple conditions to filter data in a database. The most common compound operator is the AND operator, which returns only rows that meet both conditions. The OR operator returns rows that meet either condition.

Logical operators: These operators are used to test the truth of a statement or expression. The most common logical operators are NOT, AND, and OR. NOT negates the value of the statement or expression, AND returns true if both statements are true, and OR returns true if either statement is true.

Other operators include IS NULL, IN, BETWEEN, LIKE, EXISTS, CROSS APPLY, EXCEPT, INTERSECT, etc.

It is important to note that the specific syntax and usage of these operators may vary depending on the version of SQL Server you are using and the type of query you are writing.

Arithmetic Operators Transact-SQL

Arithmetic Operators - add, subtract, multiply, divide.

Bitwise Operators Transact-SQL

Bitwise Operators - and, or, exclusive or.

Comparison Operators Transact-SQL

Comparison Operators - equal, greater than, less than, not equal.

Compound Operators Transact-SQL

Compound Operators - add equals, subtract equals, multiply equals.

Logical Operators Transact-SQL

Logical Operators - all, and, any, between, exists, in, like, not, or, some.