Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912

    Unanswered: Format numbers with commas

    Hello

    Nice simple T-SQL question that will no doubt prove totally uncontroversial

    Anyone know the easiest way to get from:
    123456789
    to
    123,456,789
    in T-SQL?

    Currently I cast my int as money, use convert to varchar with style 1 and then lop off the .00. Is there an easier way?

    Two things before you get all upset and start squealing about front ends:
    1) These are admin functions that I am running from SSMS. I don't want to go to the bother of creating an application when SSMS is perfectly adequate for what I need (namely to-a-large-degree unformatted result sets).
    2) I'm not too fussed about it just curious.

    Ta & tra la!
    Testimonial:
    pootle flump
    ur codings are working excelent.

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    good old style 1, that seems like the best approach

    i did a quick search and came up with a number of threads where this question was asked and the answer was a resounding "it's a display issue and you should do that with the front end application, not sql"

    of course, you already said you don't have an app...
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Thanks Rude-boy - I got the "do it front end" stuff too.

    Just wondered if there was something less verbose that I just don't know of. Even an SSMS setting would be fine.
    Testimonial:
    pootle flump
    ur codings are working excelent.

Posting Permissions

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