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
SELECT Column_Names FROM Table WHERE Expression IS NOT NULL
SQL IS NOT NULL Example
The following screenshot will show you the data inside the table.
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
It’s another example of the SQL Server IS NOT NULL function. Here, we are using the [Emp] table, and the data inside this table is
The following Server query returns all the employee records whose Office Phone numbers are Non-empty values.
SELECT [Id] ,[Name] ,[Education] ,[Occupation] ,[YearlyIncome] ,[Office Phone] ,[Mobile] ,[Home Phone] FROM [Emp] WHERE [Office Phone] IS NOT NULL
The below code Selects all the records whose Office numbers or Mobile numbers are NOT NULL values
SELECT [Id] ,[Name] ,[Education] ,[Occupation] ,[YearlyIncome] ,[Office Phone] ,[Mobile] ,[Home Phone] FROM [Emp] WHERE [Office Phone] IS NOT NULL OR [Mobile] IS NOT NULL