[dba-SQLServer] Formatting Numbers IN SQL

David Emerson newsgrps at dalyn.co.nz
Tue Sep 16 17:47:49 CDT 2008


I have spotted the problem - I omitted the ,1 at the end.

Thanks everyone for your help.

David

At 17/09/2008, you wrote:
>IN QA, I got the same result as Fred.
>
>12,345.00
>
>select '$ ' + CAST(convert(varchar, convert(money, 12345) ,1) AS
>VARCHAR(12)) as Cash
>
>will handle up to 9,999,999.99
>
>David
>
>On Tue, Sep 16, 2008 at 2:41 PM, David Emerson <newsgrps at dalyn.co.nz> wrote:
>
> > 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




More information about the dba-SQLServer mailing list