Solved

SQL case statement with embeded html

Posted on 2013-01-14
2
266 Views
Last Modified: 2013-01-14
The following is a SQL extract from a very long query which runs fine.  However I am trying to add some HTML formatting so that I can run the sql query within a wiki.  I have everything worked out just fine.  However I want the ?????? to return the value for bob from the database.  Currently it will return text "??????".  I want it to return the value from the database IE "25".

,CASE
      WHEN bob >= 10 THEN '<span style="background: #FFF; border: 1px solid #999;padding: 1px 12px;">??????</span>'
      WHEN bob < 10THEN '<span style="background: #FFFFF0; border: 1px solid #999;padding: 1px 12px;">??????</span>'
      WHEN bob < 5 THEN '<span style="background: #e99; border: 1px solid #999;padding: 1px 12px;">??????</span>'
      ELSE '--'
      END AS bob
0
Comment
Question by:JohnMad
2 Comments
 
LVL 35

Accepted Solution

by:
Robert Schutt earned 500 total points
ID: 38776114
try using this (3 times):
WHEN bob >= 10 THEN '<span style="background: #FFF; border: 1px solid #999;padding: 1px 12px;">' + convert(varchar, bob) + '</span>' 

Open in new window

0
 

Author Closing Comment

by:JohnMad
ID: 38776149
quick and concise help
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
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.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

749 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