SQL Server Interview Question #18

What is NULL in SQL Server?

SQL Server Fundamentals Junior Beginner

Detailed Explanation

NULL represents a missing, unknown, or unavailable value. It is not the same as zero, an empty string, or FALSE.

NULL should normally be checked using IS NULL or IS NOT NULL rather than = NULL. SQL uses three-valued logicβ€”TRUE, FALSE, and UNKNOWNβ€”so NULL can affect comparisons, filters, joins, and expressions in ways that interview candidates should understand.

Code Example

SELECT *
FROM Customers
WHERE MiddleName IS NULL;

SELECT *
FROM Customers
WHERE MiddleName IS NOT NULL;