NULL Values In SQL
  1. NULL values represent missing unknown data.
  2. By default, a table column can hold NULL values.
  3. If a column in a table is optional, we can insert a new record or update an existing record without adding a value to this column. This means that the field will be saved with a NULL value.
  4. NULL values are treated differently from other values.
  5. NULL is used as a placeholder for unknown or inapplicable values.
  6. It is not possible to compare NULL and 0; they are not equivalent.


First of all we create a table in SQL Server and insert some as shown in below.



  

CREATE TABLE tblTestSample
(
Id int primary key,FirstName varchar(50),LastName varchar(50) Null,Email nvarchar(100)
)


----------INSERT SOME RECORDS----------

INSERT INTO tblTestSample VALUES(1001,'Santosh','','s@gmail.com')
INSERT INTO tblTestSample VALUES(1002,'POOJA KUMARI','','p@gmail.com')
INSERT INTO tblTestSample VALUES(1003,'POOJA KUMARI','sharma','pr@gmail.com')
INSERT INTO tblTestSample VALUES(1004,'Kalpna','','k@gmail.com')
INSERT INTO tblTestSample VALUES(1005,'Pramod','Sah','p@gmail.com')



Now, display some null values.

  

SELECT * FROM tblTestSample WHERE LastName IS NULL

---------------- IS NOT NULL-----------------

SELECT * FROM tblTestSample WHERE LastName IS NOT NULL