Wednesday, March 7, 2012

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!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...|||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.

No comments:

Post a Comment