can we display a number in this format

  • hi,

    my currency data loaded as following

    currency

    ---------

    1000

    2223

    45000

    when i am querying i want to display like follows

    currency

    ---------

    1,000

    2,223

    45,000

    what function i can use in mssql. is it possible or not?

  • Normally you allow the UI to handle formatting as they have formatting functions that are simple to use.

    From BOL for converting money/smallmoney:

    The following table shows the values for style that can be used for converting money or smallmoney to character data.

    Value Output

    0 (default)

    No commas every three digits to the left of the decimal point, and two digits to the right of the decimal point; for example, 4235.98.

    1

    Commas every three digits to the left of the decimal point, and two digits to the right of the decimal point; for example, 3,510.92.

    2

    No commas every three digits to the left of the decimal point, and four digits to the right of the decimal point; for example, 4235.9819.

    The data type has to be money/smallmoney.

    I still recommend doing formatting in the UI.

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

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