List Rows with NULL values in a Column in SQL Server

A NULL value represents the missing data, or an unknown value. To find rows that have or that don't have NULL values in a column, use IS NULL and IS NOT NULL instead of comparison operators (=, !=, <>).

To list all rows that have NULL value in the MiddleName column in the Person.Person table in the AdventureWorks Database use this query:

USE AdventureWorks
SELECT FirstName, MiddleName, LastName
FROM Person.Person
WHERE MiddleName IS NULL

is_null_middlename

To list all rows that don't have NULL value in the MiddleName column in the Person.Person table in the AdventureWorks Database use this query:

USE AdventureWorks
SELECT FirstName, MiddleName, LastName
FROM Person.Person
WHERE MiddleName IS NOT NULL

is_not_null_middlename

Related articles:
‘Not Equal To’ comparison operators in SQL Server
List all Nullable or Non-Nullable Columns in a SQL Server Table
How to replace NULL with a different value in a query result in SQL Server

If the post helped you, please share it:
Pin It

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">