Solved

SQL case statement with embeded html

Posted on 2013-01-14
2
268 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
[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
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 Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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…
In this article I will describe the Copy Database Wizard 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.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

732 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