Month End Sale: Get Extra 10% OFF on Job-oriented Training! Offer Ending in
D
H
M
S
Get Now

SQL Server Operators

Level : Beginner
Mentor: Shailendra Chauhan
Duration : 00:02:00

Arithmetic Operators

Arithmetic operators perform mathematical calculations on numeric values.

Example

SELECT 5 + 3 AS Addition, 10 - 4 AS Subtraction, 6 * 2 AS Multiplication, 16 / 4 AS Division;

Relational Operators

Relational operators compare values to determine if they meet specific relationships (e.g., equal, not equal, greater than, less than).

Example

SELECT 5 = 5 AS Equal, 10 <> 5 AS NotEqual, 8 > 3 AS GreaterThan, 3 < 7 AS LessThan;

Assignment Operator

The assignment operator (=) assigns a value to a variable.

Example

DECLARE @x INT;
SET @x = 10;
SELECT @x AS Result;

Scope Resolution Operator

SQL Server uses schema and table names separated by a dot (.) to resolve the scope of an object.

Example

SELECT dbo.Employee.Name FROM dbo.Employee;

Bitwise Operators

Bitwise operators perform operations at the bit level for integers.

Example

DECLARE @a INT = 5, @b INT = 3;
SELECT @a & @b AS BitwiseAND, @a | @b AS BitwiseOR, ~@a AS BitwiseNOT;

Set Operators (EXCEPT, INTERSECT, UNION)

Set operators combine or compare result sets from multiple queries.

Example

SELECT employee_id FROM Employees
UNION
SELECT employee_id FROM FormerEmployees;

Comparison Operators

Comparison operators compare values to evaluate conditions in SQL queries.

Example

SELECT product_name FROM Products WHERE price > 50;

String Concatenation Operator

The concatenation operator (+) combines strings in SQL Server.

Example

SELECT first_name + ' ' + last_name AS full_name FROM Employees;

Compound Operators

Compound operators combine an operation with the assignment (e.g., +=, -=).

Example

DECLARE @total INT = 10;
SET @total += 5;

Unary Operators

Unary operators work on a single operand.

Example

SELECT -5 AS Negation, NOT 1 AS LogicalNOT;

Logical Operators

Logical operators combine conditions to evaluate logical expressions.

Example

SELECT product_name FROM Products WHERE in_stock = 1 AND price < 50;
Self-paced Membership
  • 22+ Video Courses
  • 800+ Hands-On Labs
  • 400+ Quick Notes
  • 55+ Skill Tests
  • 45+ Interview Q&A Courses
  • 10+ Real-world Projects
  • Career Coaching Sessions
  • Email Support
Upto 60% OFF
Know More
Still have some questions? Let's discuss.
CONTACT US
Accept cookies & close this