Improve company productivity with a Business Account.Sign Up

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 5756
  • Last Modified:

SQL equivalent to Oracle's 'NVL'

What's the SQL Server equivalent to the Oracle 'NVL' function?  
I want to replace a null field with "N/A"
  • 2
1 Solution
Eugene ZCommented:


 COALESCE(expr1 {, exprN })  

COALESCE returns the first expression that is not NULL. The expressions are evaluated in the order in which they are specified. This function is usually used to replace NULL values with a not NULL value.


This example selects title and price for all books. If the price for a given title is NULL, the price shown is 0.00.

SELECT title, COALESCE(price, 0.00) AS price
FROM titles;

Equivalents in other databases

 IBM DB2   COALESCE function  
 Oracle   NVL function  

Eugene ZCommented:
and replace NULL

 function  ISNULL(price, 'N\A') --replace null wiht 'N\A'
natejacobsAuthor Commented:
ISNULL!  that's what I was trying to remember
coalesce is a much better answer, since you can pass in 2 or 3 or 12 arguments and it returns the first nonnull
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now