From the course: Complete Guide to Advanced SQL Server

Unlock the full course today

Join today to access over 24,400 courses taught by industry experts.

Understand NULL values

Understand NULL values

It's common to misunderstand a null value as meaning zero or nothing, but that isn't the case. Null values have special meaning to SQL Server. They represent values that are unknown, missing, or not knowable. This difference has a big impact when you start trying to compare columns that contain nulls. For instance, when creating joins between two tables. If the columns in the JOIN clause of a SELECT statement include null values, then you might not actually see all of the rows in the results that you intended to see. To illustrate how SQL Server treats null values, I've set up another pair of variables called variable A and variable B. Both of these are set to the INT data type. We can set their values on Lines 8 and 9, and then test the two variables for equality using a CASE statement. If variable A is equal to variable B, then the results will say "Equal." And if the two variables are not equal, then the results will say "Not Equal." So right now I have the two variables set to the…

Contents