Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2006
    Posts
    115

    Unanswered: thousand seperator

    pls advise how a sql to return numeric value with thousand seperator...
    e.g
    declare @a int
    select @a=1234567.89

    expected return:
    a
    ---
    1,234,567.89

  2. #2
    Join Date
    Sep 2003
    Location
    Switzerland
    Posts
    443
    You need to have either numeric or money and not an int for a money value if you need to maintain decimal values in the column


    Two options either declare the variable as money or use convert function when printing.

    1> declare @a numeric(10,2)
    2> select @a=1234567.89
    3> select convert(money,@a)
    4>
    5> declare @b money
    6> select @b=1234567.89
    7> select @b
    8> go
    (1 row affected)

    ------------------------
    1,234,567.89

    (1 row affected)
    (1 row affected)

    ------------------------
    1,234,567.89

    (1 row affected)
    Last edited by trvishi; 01-13-09 at 05:46.

  3. #3
    Join Date
    Jul 2006
    Posts
    115
    thx a lot ...

  4. #4
    Join Date
    Mar 2009
    Location
    Sydney, Australia
    Posts
    258
    That's not quite correct.

    ISQL does an automatic formatting for money datatype, and ISQL prints it with comma separators and a decimal point.

    SQL does not. Both numeric and money remain in their internal representation. It is the Client programs job to perform formatting, rendering, etc. Depending on the Client app that I use, I get various and different results re the commas and decimal point, auto-conversion, automatic treatment of money, etc; eg. DBArtisan prints "1234567.89" for the above numeric and money values.
    Regards
    Derek Asirvadem (Formerly DerekA)
    Information Architect / Senior Sybase DBA
    Copyright 2009 Software Gems Pty Ltd

    I answer questions from the Original Poster only. If you have a genuine question, as the moderators have requested, start a new thread.

    http://www.softwaregems.com.au

Posting Permissions

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