Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2005

    Unanswered: format output as scientific notation (was "sql 2000 question")

    PHP Code:
    SELECT membernameoutputval
    case when choice 0 then outputval else null end as outputval
    from MyDatabase
    group by membername
    how to format outputval:
    if outputval < 40000
    format outputval as:
    5 - 5.78 - 6.9 - 6,778 - 4,567.8 - 12,456.78 - etc.
    if outputval >= 40000
    format it as a scientific.

  2. #2
    Join Date
    Feb 2004
    In front of the computer
    Provided Answers: 54
    I would strongly suggest that you do the formatting at either the web server (using PHP), or better yet at the client (possibly using Javascript). This would allow you to use locale specific information that isn't usually available to SQL Server.

    If you really have to format the output at the SQL Server, it could be done using a SQL UDF that called xp_sprintf or other related tools. This means that every query will need to be formatted using the locale of your SQL Server, which is usually a huge problem for application globalization.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts