Home > Archive > microsoft.public.sqlserver.server > July 2003 > Numeric Comma Separators





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Numeric Comma Separators
Deane Barker

2002-12-11, 10:24 am

Is there any way to get SQL to format numbers with the comma
separator? For instance, a integer value in the database is...

100000

....but I want it to come from the SQL statement out as...

1,000,000

Is this possible? How about money: a float of 2.71 comes out as
$2.71.

Deane
Jacco Schalkwijk

2002-12-11, 11:24 am

That's something that is far better handled in your client application. Just
set the appropriate options in Access, VB or what other you might be using.

--
Jacco Schalkwijk MCDBA, MCSD, MCSE
Database Administrator
Eurostop Ltd.


"Deane Barker" <deane@slingandrock.com> wrote in message
news:3ee9b2f.0212110813.46e22131@posting.google.com...
> Is there any way to get SQL to format numbers with the comma
> separator? For instance, a integer value in the database is...
>
> 100000
>
> ...but I want it to come from the SQL statement out as...
>
> 1,000,000
>
> Is this possible? How about money: a float of 2.71 comes out as
> $2.71.
>
> Deane



Narayana Vyas Kondreddi

2002-12-11, 11:24 am

CONVERT function can do this for you, is you pass money/smallmoney values.
--
HTH,
Vyas, MVP (SQL Server)
SQL Server FAQ, articles, code samples, interview questions and more @
http://vyaskn.tripod.com/


"Deane Barker" <deane@slingandrock.com> wrote in message
news:3ee9b2f.0212110813.46e22131@posting.google.com...
> Is there any way to get SQL to format numbers with the comma
> separator? For instance, a integer value in the database is...
>
> 100000
>
> ...but I want it to come from the SQL statement out as...
>
> 1,000,000
>
> Is this possible? How about money: a float of 2.71 comes out as
> $2.71.
>
> Deane



Anith Sen

2002-12-11, 11:24 am

Like Jacco said, it is always recommended that you do all your
formatting in your client application. In T-SQL you can do:

DECLARE @intVal INT
SET @intVal = 100000
SELECT '$' + CONVERT(VARCHAR, CAST(100000 AS MONEY), 1)

--
- Anith
(Please respond only to newsgroups)




jonreade

2003-07-01, 7:39 am

Mmmmmmmmm, that's all very fine, but what if you're not coding up an app? Some people actually use SQL Server without VB (!!), for instance for creating a data feed. In such cases, formatting it through an app. would be an incredible waste of resources.
Sponsored Links





Free Braindumps | MCSE braindumps software forum

Copyright 2003 - 2008 examnotes.net