[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

SQL equivalent to Oracle's 'NVL'

Posted on 2004-08-04
4
Medium Priority
?
5,718 Views
Last Modified: 2012-06-21
What's the SQL Server equivalent to the Oracle 'NVL' function?  
I want to replace a null field with "N/A"
0
Comment
Question by:natejacobs
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 43

Expert Comment

by:Eugene Z
ID: 11719799
from http://www.ispirer.com/doc/sqlways36/sqlserver/mssql_fn.html:

COALESCE
Syntax


 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.

Example

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  

0
 
LVL 43

Accepted Solution

by:
Eugene Z earned 1000 total points
ID: 11719814
and replace NULL

 function  ISNULL(price, 'N\A') --replace null wiht 'N\A'
0
 
LVL 3

Author Comment

by:natejacobs
ID: 11719878
ISNULL!  that's what I was trying to remember
0
 
LVL 1

Expert Comment

by:aaronkempf
ID: 11719966
coalesce is a much better answer, since you can pass in 2 or 3 or 12 arguments and it returns the first nonnull
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question