Real world example of NULLIF : If you want to compare column with empty string or null condition in SQL Server then generally we are write two condition with OR operator.
Sample : SELECT COLUMN1,COLUMN2 FROM TABLE1 WHERE ( COLUMN1 IS NULL OR COLUMN1 = ‘’)
Instead of writing two condition you can use NULLIF function and write the Single condition.
Sample : SELECT COLUMN1,COLUMN2 FROM TABLE1 WHERE NULLIF (COLUMN1,’’) IS NULL
No comments:
Post a Comment