Solved

SQL case statement with embeded html

Posted on 2013-01-14
2
262 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

I have written a PowerShell script to "walk" the security structure of each SQL instance to find:         Each Login (Windows or SQL)             * Its Server Roles             * Every database to which the login is mapped             * The associated "Database User" for this …
How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

911 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

15 Experts available now in Live!

Get 1:1 Help Now