Solved

Return value only if column is NULL

Posted on 2013-01-17
6
377 Views
Last Modified: 2013-01-17
I want to return a value only if the column is null.

isnull(MenuName, 'Not Used') AS MenuUsage

Something like the above... If it is null, I want the column to be 'Not Used'
If it is not null, I want it blank and to say nothing, I don't want it to return the Menu Name.

How do I do that?

thanks!
0
Comment
Question by:Starr Duskk
  • 3
  • 2
6 Comments
 
LVL 65

Assisted Solution

by:Jim Horn
Jim Horn earned 20 total points
ID: 38789560
CASE COALESCE(MenuName, 'Not Used')
   WHEN 'Not Used' THEN 'Not Used' ELSE '' END

COALESCE eturns the first non-null value, which will either be the contents of MenuName, or in this case an empty string ''
0
 
LVL 2

Accepted Solution

by:
thombeck earned 480 total points
ID: 38789568
Hi,


use :

select
   Case when MenuName is Null
     Then 'Not Used'
     Else ''
    End
0
 
LVL 1

Author Closing Comment

by:Starr Duskk
ID: 38789639
perfect!
0
Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

 
LVL 65

Expert Comment

by:Jim Horn
ID: 38789659
Please explain how my solution did not meet your needs.
After re-reading your question a couple of times I'm not seeing anything that was missed.
0
 
LVL 1

Author Comment

by:Starr Duskk
ID: 38789773
yours errored when I used it with an integer field and the other did not.
0
 
LVL 65

Expert Comment

by:Jim Horn
ID: 38789927
Fair enough
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
DATETIMEOFFSET feature 1 33
MS SQL - Rotating Values in SQL 9 55
Dimension table indexes 8 13
Getting max record but maybe not use Group BY 2 17
How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

867 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now