ASP.NET (35) SQL (25) JAVASCRIPT (24) HTML (14) STYLE SHEET (6) ASP (4) SCRIPT (1)

Search me out HERE!!

NULLIF and ISNULL in SQL

ISNULL
Syntax: ISNULL(expression, value)
Explanation: This function will check expression value and if expression is NULL then it will replace it will given value.
Example: SELECT ISNULL(Income,0) AS Income FROM EmpDetail
Here if Income is NULL for any employee then it will return as 0.

NULLIF
Syntax: NULLIF(expression, value)
Explanation: This function will check expression value and if expression = value then it will replace it with NULL (This function is opposite of ISNULL).
Example: SELECT NULLIF(Income,0) AS Income FROM EmpDetail
Here if Income is 0 for any employee then it will return as NULL.

No comments:

Post a Comment