SQL IS NOT NULL

The SQL IS NOT NULL is useful to find whether the specified expression is nullable; if it is not, then TRUE will be returned. Otherwise, it returns FALSE. It is always advisable to use IS NOT to look for NULL values.

The syntax behind this IS NOT NUL operator is as shown below.

SELECT Column_Names 
FROM Table
WHERE Expression IS NOT NULL

SQL Server IS NOT NULL Example

The following screenshot will show you the data inside the table.

Source Table data 1

In this example, we will use this to SELECT and return all the customer records from the [TenCustomers] table, whose Last Name is NOT Nullable value

SELECT [CustomerKey]
      ,[FirstName]
      ,[LastName]
      ,[EmailAddress]
      ,[YearlyIncome]
      ,[EnglishOccupation]
      ,[AddressLine1]
      ,[Phone]
  FROM [TenCustomers]
  WHERE [LastName] IS NOT NULL
IS NOT NULL Example 2

It’s another example of the IS NOT NULL function. Here, we are using the [Emp] table, and the data inside this table is

Employee table with a few empty phone numbers

The following Server query returns all the employee records whose Office Phone numbers are Non-empty values. For more topics, refer to the SQL Server tutorial.

SELECT [Id]
      ,[Name]
      ,[Education]
      ,[Occupation]
      ,[YearlyIncome]
      ,[Office Phone]
      ,[Mobile]
      ,[Home Phone]
  FROM [Emp]
  WHERE [Office Phone] IS NOT NULL
Example 3

The code below selects all the records whose Office numbers or Mobile numbers are NOT NULL values. For more NULL operations, please refer to the SQL COALESCE, SQL IS NULL, and SQL ISNULL functions.

SELECT [Id]
      ,[Name]
      ,[Education]
      ,[Occupation]
      ,[YearlyIncome]
      ,[Office Phone]
      ,[Mobile]
      ,[Home Phone]
  FROM [Emp]
  WHERE [Office Phone] IS NOT NULL OR 
	[Mobile] IS NOT NULL
IS NOT NULL Example 4
Categories SQL