Sunday, February 19, 2012

format 0.00 decimal value

Is there any option/settings in SQL server to return 0 decimal value as
"0.00"
not
".00"
I can do it by converting all results to varchar(), but is there any easy
way? may be server settings?
thanks
LFormatting of decimal data is done by the front end, not the server.
So the problem is with Query Analyzer, or whatever tool you are using.
If it is QA there is no feature like you are asking for.
Roy Harvey
Beacon Falls, CT
On Wed, 29 Nov 2006 13:43:01 -0800, LLT
<LLT@.discussions.microsoft.com> wrote:

>Is there any option/settings in SQL server to return 0 decimal value as
>"0.00"
>not
>".00"
>I can do it by converting all results to varchar(), but is there any easy
>way? may be server settings?
>thanks
>L|||I am using QA. The same in DTS when I extract data into txt file. Strange,
but float is returned with leading 0 as "0.00", decimal and money without as
".00". When number converted to string using cast() or str() leading 0 is
shown for all numbers.
You can run in in QA.
select 'money, with varchar cast', cast(cast (0.00 as money) as varchar(10)
)
select 'money, no varchar cast', cast(0.00 as money)
select 'decimal(10,2) with varchar cast', cast(cast (0.00 as decimal(10,2))
as varchar(10))
select 'decimal, no varchar cast', cast(0.00 as decimal(10,2))
select 'float, with varchar cast', cast(cast (0.00 as float) as varchar(10))
select 'float, no varchar cast', cast(0.00 as float)
"Roy Harvey" wrote:

> Formatting of decimal data is done by the front end, not the server.
> So the problem is with Query Analyzer, or whatever tool you are using.
> If it is QA there is no feature like you are asking for.
> Roy Harvey
> Beacon Falls, CT
> On Wed, 29 Nov 2006 13:43:01 -0800, LLT
> <LLT@.discussions.microsoft.com> wrote:
>
>

No comments:

Post a Comment