How to Check for NULL value in a Query in SQL Server ?

Published on August 17, 2016 by abundantcode

Filed under SQL Server

Last modified August 17, 2016

Print this page

rate 1 star rate 2 star rate 3 star rate 4 star rate 5 star
Your rating: none, Average: 0 (0 votes)

This article have been viewed 4429 times

You might want to check if a column contains a NULL value or NOT and filter the rows. You can use the IS NULL and IS NOT NULL keywords in SQL Server to perform the NULL check.

How to Check for NULL value in a Query in SQL Server ?

The NULL values cannot be easily identified using the = operator because the NULL refers to NO value. Using the IS NULL in SQL Server performs this NULL check to return true when the value of the column is NULL.

For example , if you want to retrieve the Employee records where the column organizationNode column contains NULL value , the query will be as follows.

use AdventureWorks2014
GO
SELECT * FROM HumanResources.Employee
where OrganizationNode IS NULL

The output of the above query is

image

Leave a Comment


x

You might be Interested in these Posts

C Program to find the G.C.D of a number using Recursive function

Problem Write a program in C to find the find the G.C.D of a number using recursion and display the ...

C Program to print a Half Pyramid using *

Problem Write a program in C to print Half pyramid using * as shown. * * * * * * * * * * ...

C Program to display Positive factors of a number

Problem Write a program in C to display all the positive factors of a number enter by the user. Ho...