Logo 
Search:

SQL Server Articles

Submit Article
Home » Articles » SQL Server » System FunctionsRSS Feeds

ISNULL Function

Posted By: Sarita Patel     Category: SQL Server     Views: 2409

This article explains about ISNULL function in sql server with examples.

ISNULL function is used to replace null with specified value.  


Syntax of ISNULL Function :

ISNULL (check_expression ,replacement_value)

check_expression is any valid sql server expression to be checked for NULL value. It can be of any type.

replacement_value is any valid sql server expression to be returned when checked_expression is null. 

Data type of checked_expression and replacement_value must be same.

Return type of ISNULL function is same as check_expression.




Examples of ISNULL Function :

Example 1 : Use of ISNULL function in select clause 

SELECT ContactName, ISNULL(Fax,'Not Available') AS Fax
FROM    Customers

Output
ContactName                 Fax
Elizabeth Lincoln            (604) 555-3745
Victoria Ashworth          Not Available
Patricio Simpson            (1) 135-4892
Francisco Chang            (5) 555-7293
Yang Wang                   Not Available
Pedro Afonso                Not Available
Elizabeth Brown            (171) 555-9199

Above example returns customers name and fax number by substituting null where fax number is not available.
  
Share: 

 
 
 

Didn't find what you were looking for? Find more on ISNULL Function Or get search suggestion and latest updates.

Sarita Patel
Sarita Patel author of ISNULL Function is from United States.
 
View All Articles

Related Articles and Code:


 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!