SQL Server Tutorial SQL Server Advanced SQL Server Database SQL Server References

SQL Server - Equal to (=) Operator



The SQL Server (Transact-SQL) = (equal to) operator checks if the value of left operand is equal to the value of right operand and returns true if the condition is true, false otherwise.

Note: The = operator is also used to assign value (for example assigning values with UPDATE statement).

Syntax

The syntax for using equal to operator in SQL Server (Transact-SQL) is given below:

expression = expression  

Parameters

expression Any valid expression. Both expressions must have implicitly convertible data types.

Example:

Consider a database table called Employee with the following records:

EmpIDNameCityAgeSalary
1JohnLondon253000
2MarryNew York242750
3JoParis272800
4KimAmsterdam303100
5RameshNew Delhi283000
6HuangBeijing282800

To select records of table where Age of the person is equal to 28, the query is given below.

SELECT * FROM Employee
WHERE Age = 28;

The query will produce following result:

EmpIDNameCityAgeSalary
5RameshNew Delhi283000
6HuangBeijing282800

❮ SQL Server Operators