• Thom A - Wednesday, July 19, 2017 4:30 AM

    sqlenthu 89358 - Wednesday, July 19, 2017 4:17 AM

    Selectcase when RevAmtMax <0 then '<font color="red">' + '($'+replace(convert(varchar,convert(money,RevAmtMax,1), '.00','') +')' + '</font>' else '$'+  replace(convert(varchar,convert(money,RevAmtMax,1), '.00','') +')' end + '/ '
    case when RevAmtMin <0 then '<font color="red">' + '($'+replace(convert(varchar,convert(money,RevAmtMax,1), '.00','') +')' +'</font>' else '$'+replace(convert(varchar,convert(money,RevAmtMax,1), '.00','') +')' end
    From #mytable

    You've still excluded the replacement of the escape string (for example &gt; (which represents greater than ( > ))), and there's no FOR XML PATH, so this isn;t going to work. You need to do this on your variable, as shown in my example above.

    Have a look at the SQL I posted after your initial question. There are several statements in there, for example the creation of the table header, and the replace I mentioned above, but the above is only one. The whole process requires all of these steps to work. The bit that fixes the escape strings is commented as "--Remove Escape Characters".

    if you don't understand a part of my SQL at the start, please ask. it's important that you understand the answers yo are provided, rather than just using it and then being unable to troubleshoot it.

    Hey Thom. Thanks for your help. It worked perfectly. I actually missed the REPLACE command and that's why was getting issue. Sorry for late response as i was down with fever from past some days.