Format Negative Number

  • I was asked today, if I knew how to format a negative number from displaying -9 to (9).  The only thing I can think of is Select Case when x<0 then ‘(‘+convert(varchar(13),neg(x))+’)’ else convert(varchar(13),x) end

    Is there some SQL function that will do this? I couldn't find anything under convert or cast that would do this.

    Thank you,

    Carol

  • Unfortunately, there is no easy way of getting SQL to FORMAT like EXCEL.  What you probably could do is take your code above and build it into a function that would be called in-line...



    Good Hunting!

    AJ Ahrens


    webmaster@kritter.net

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply