[dba-SQLServer] Formatting Numbers IN SQL

Fred Hooper fahooper at trapo.com
Tue Sep 16 16:58:05 CDT 2008


Hi David,

I don't have 2000 to test on, but the documentation
(http://msdn.microsoft.com/en-us/library/aa226054(SQL.80).aspx) says it
ought to work. Maybe you have a regional setting that's affecting it, (I
found a link where an integer was formatted with commas that was due to a
regional setting -- perhaps you have the opposite effect).

You could also try the DLL at
http://www.databasepronews.com/articles/0220df.html if it's important
enough. (I haven't tried it, just found it.)

Fred

-----Original Message-----
From: dba-sqlserver-bounces at databaseadvisors.com
[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of David
Emerson
Sent: Tuesday, September 16, 2008 5:42 PM
To: Discussion concerning MS SQL Server
Subject: Re: [dba-SQLServer] Formatting Numbers IN SQL

I tried that but still got "12345.00"

I am using SQL2000.

Regards

David

At 17/09/2008, you wrote:
>If you only want two decimal places you can use money, like this:
>
>select convert(varchar, convert(money, 12345) ,1)
>
>returns "12,345.00"
>
>-----Original Message-----
>From: dba-sqlserver-bounces at databaseadvisors.com
>[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of David
>Emerson
>Sent: Tuesday, September 16, 2008 1:20 PM
>To: dba-SQLServer at databaseadvisors.com
>Subject: [dba-SQLServer] Formatting Numbers IN SQL
>
>Since I didn't get a reply I will try another tact.
>
>There doesn't seem to be an SQL equivalent to the Access
>Format(12345,"#,##0").  What is the simplest way of taking a number
>like 12345.00 and converting it to a varchar "12,345"?
>
>
>Regards
>
>David Emerson
>Dalyn Software Ltd
>Wellington, New Zealand
>
>_______________________________________________
>dba-SQLServer mailing list
>dba-SQLServer at databaseadvisors.com
>http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
>http://www.databaseadvisors.com
>
>_______________________________________________
>dba-SQLServer mailing list
>dba-SQLServer at databaseadvisors.com
>http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
>http://www.databaseadvisors.com

_______________________________________________
dba-SQLServer mailing list
dba-SQLServer at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
http://www.databaseadvisors.com




More information about the dba-SQLServer mailing list