SQL Server Interview Question #44

What are comparison operators in SQL Server?

SELECT, Filtering, Sorting & Built-in Functions Mid-Level Intermediate

Detailed Explanation

Comparison operators compare expressions and are commonly used in WHERE, HAVING, JOIN conditions, CASE expressions, and other predicates.

Common operators include =, <>, !=, >, <, >=, and <=. SQL Server supports both <> and != for 'not equal', although <> is the standard SQL form.

Comparisons involving NULL generally produce UNKNOWN rather than TRUE or FALSE, so NULL should normally be tested with IS NULL or IS NOT NULL.

Code Example

SELECT *
FROM dbo.Products
WHERE Price >= 100
  AND Price <> 500;