?
Solved

Return value only if column is NULL

Posted on 2013-01-17
6
Medium Priority
?
383 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
[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
  • 3
  • 2
6 Comments
 
LVL 66

Assisted Solution

by:Jim Horn
Jim Horn earned 80 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 1920 total points
ID: 38789568
Hi,


use :

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

Author Closing Comment

by:Starr Duskk
ID: 38789639
perfect!
0
Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

 
LVL 66

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 2

Author Comment

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

Expert Comment

by:Jim Horn
ID: 38789927
Fair enough
0

Featured Post

Does Your Cloud Backup Use Blockchain Technology?

Blockchain technology has already revolutionized finance thanks to Bitcoin. Now it's disrupting other areas, including the realm of data protection. Learn how blockchain is now being used to authenticate backup files and keep them safe from hackers.

Question has a verified solution.

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

This is basically a blog post I wrote recently. I've found that SARGability is poorly understood, and since many people don't read blogs, I figured I'd post it here as an article. SARGable is an adjective in SQL that means that an item can be fou…
SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

771 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