Friday, March 9, 2012

Decimal value

When I use cast:
cast(100*T1.value1/T1.value2 as decimal(18,2))
I always get dot for decimal point, for example 10.2
Is it possible to get comma for decimal point, for example 10,2
Thank you,
SimonSimon,
The expression cast(... as decimal(18,2)) is a number, not a character
string, and its display format depends on how the client application you are
using displays decimal values. If you want to be sure a comma is
displayed, you can have SQL Server send a character string. Since
converting from decimal to character string within SQL Server results
in a . as decimal point, this should work:
replace(cast(... as decimal(18,2)),'.',',')
Note that you will now be returning a character string, and your client
program may again format the display differently than you expect. For
example, strings and numbers may be aligned differently.
Steve Kass
Drew University
simon wrote:

>When I use cast:
>cast(100*T1.value1/T1.value2 as decimal(18,2))
>I always get dot for decimal point, for example 10.2
>Is it possible to get comma for decimal point, for example 10,2
>Thank you,
>Simon
>
>|||In QA go to Tools - Options... - Connections and check "Use regional setting
s
when displaying currency, number, dates and times"
AMB
"simon" wrote:

> When I use cast:
> cast(100*T1.value1/T1.value2 as decimal(18,2))
> I always get dot for decimal point, for example 10.2
> Is it possible to get comma for decimal point, for example 10,2
> Thank you,
> Simon
>|||simon,
You could do:
REPLACE(cast(100*T1.value1/T1.value2 as decimal(18,2)), '.', ',')
But then it will no longer be numeric. You should probably do this sort of
thing in the front end.
-Andy
"simon" <simon.zupan@.stud-moderna.si> wrote in message
news:OWjFLSTNFHA.3788@.tk2msftngp13.phx.gbl...
When I use cast:
cast(100*T1.value1/T1.value2 as decimal(18,2))
I always get dot for decimal point, for example 10.2
Is it possible to get comma for decimal point, for example 10,2
Thank you,
Simon

No comments:

Post a Comment