Solved

SQL case statement with embeded html

Posted on 2013-01-14
2
261 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
Comment Utility
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
Comment Utility
quick and concise help
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Join & Write a Comment

Suggested Solutions

After restoring a Microsoft SQL Server database (.bak) from backup or attaching .mdf file, you may run into "Error '15023' User or role already exists in the current database" when you use the "User Mapping" SQL Management Studio functionality to al…
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 video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now