Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Format number results in TSQL Expand / Collapse
Author
Message
Posted Monday, August 30, 2010 2:22 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Tuesday, February 15, 2011 7:18 AM
Points: 14, Visits: 45
I have a TSQL Query which selects data from a decimal(25,6) field.
The result has the following format: 25.000000

I want to be: 25,00

How can I cast it and convert it.

Regards,
K
Post #977189
Posted Monday, August 30, 2010 2:27 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Monday, November 17, 2014 4:22 PM
Points: 2,262, Visits: 5,421
dint this work?

select cast( 25.000000 as decimal(25,2))

Post #977192
Posted Monday, August 30, 2010 2:34 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Tuesday, February 15, 2011 7:18 AM
Points: 14, Visits: 45
It returns 25.00 with "." separator.

I want to have comma separator (",")

Any help?
Post #977195
Posted Monday, August 30, 2010 2:47 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Monday, November 17, 2014 4:22 PM
Points: 2,262, Visits: 5,421
Probably there is a straight-forward way, but this is what i have come up with :

select replace(cast ( convert(decimal(25,2),25.00) as varchar) , '.' , ',') Comma_Value

Post #977196
Posted Monday, August 30, 2010 2:52 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Tuesday, February 15, 2011 7:18 AM
Points: 14, Visits: 45
Thanks
Post #977197
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse