Solved

Give NULL value a name in SQL View

Posted on 2014-01-12
3
433 Views
Last Modified: 2014-01-12
I have a view that I want to give a name to the "NULL" in the column  "Not Entered" would be the new value shown if it is "NULL"  if that makes sense...

Example of current Query
0
Comment
Question by:srodgers45
3 Comments
 
LVL 16

Accepted Solution

by:
Surendra Nath earned 500 total points
ID: 39775113
You can do it as below
change your select in your query as below

SELECT top (100) <all your columns as is now except trans agency >, CASE WHEN FDC_trans_agencies.descr IS NULL THEN ' NOT ENTERED' ELSE FDC_trans_agencies.descr END as [trans agency] <followed by the where as is>

NOTE: in the above statement the statement are to be replaced with what I said including the <>....
0
 
LVL 65

Expert Comment

by:Jim Horn
ID: 39775117
Use ISNULL

SELECT blah, blah, blah, ISNULL(column_name, 'Not Entered') as column_name
FROM your_table

COALESCE can also be used if you want to pull this off using more than one column, but for your question above ISNULL works.
0
 

Author Closing Comment

by:srodgers45
ID: 39775191
Thanks for the quick response. It worked...
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

914 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

20 Experts available now in Live!

Get 1:1 Help Now