Scenario:Let's say that you are working as SQL Server developer. You need to write two queries
1) Return all the records from dbo.Customer table where Address column has Null values
2) Return only the records from dbo.Customer table where Address column has the values other than Null.
Solution :We can use Where clause in our Select statement to return null records or not null records. Let's create dbo.Customer table first and insert couple of records.
--Create dbo.Customer table Create table dbo.Customer( Id int, Name VARCHAR(100), Address VARCHAR(100)) --Insert records in dbo.Customer table Insert into dbo.Customer Values(1,'Aamir','XyZ Address') ,(2,'Raza',Null) --Return all records from dbo.Custoemr Table Select * From dbo.Customer
|Return all records from a table by using Select statement in SQL Server Database - SQL Server / TSQL Tutorial|
Select * From dbo.Customer where Address is Null
|How to get records with Null values in Select query in SQL Server Database - SQL Server / TSQL Tutorial|
Select * From dbo.Customer where Address is not Null
|Get all the records from table where column has the value beside Null values in SQL Server Database|