Home All Groups Group Topic Archive Search About

limit the number of decimals on a float field

Author
12 Aug 2006 12:57 PM
Henry
Hi

Does anyone know how to limit the numbers of decimals after the point in a
query?

cheers
Henry

Author
12 Aug 2006 2:10 PM
ML
Cast as decimal? Why use float at all?


ML

---
http://milambda.blogspot.com/
Author
12 Aug 2006 2:25 PM
Hari Prasad
Hi,

Allways for fixed scales go for Numeric data types.

Declare @a float
set @a= 10.253612
select Convert(numeric(10,2),@a)

Thanks
Hari
SQL Server MVP

Show quote
"Henry" <n**@il.com> wrote in message
news:O2nns7gvGHA.3552@TK2MSFTNGP03.phx.gbl...
> Hi
>
> Does anyone know how to limit the numbers of decimals after the point in a
> query?
>
> cheers
> Henry
>
Author
12 Aug 2006 2:46 PM
Henry
>
> Allways for fixed scales go for Numeric data types.
>
> Declare @a float
> set @a= 10.253612
> select Convert(numeric(10,2),@a)
>

Well, I didn't chose the type, and I cannot change it.

It actually help a little, but when the value is zero the it looks ugly

..00 should at least be 0.00 right?

regards
Henry


arname
id          NoOfLogs    Sidste time  Sidste uge   Sidste mned Periode
----------------------------------------------------------------------------------------------------
----------- ----------- ------------ ------------ ------------ ------------
Lan1_1_Lej_101A.X6991_P04_LastAccumDay
2           32          .00          85.90        173.17       586.19
Lan1_1_Lej_101A.X5696_P41_J_LastAccumDay
6           32          .00          .00          1.00         221.00
Lan1_1_Lej_101A.X5991_P05_LastAccumDay
3           32          .00          .47          .83          3.05
Lan1_1_Lej_101A.X5991_P06_LastAccumDay
4           32          .00          .39          .89          3.27
Lan1_1_Lej_101A.X5696_P41_Z_LastAccumDay
7           32          .00          .00          .40          34.38
Lan1_1_Lej_101A.X5991_P07_LastAccumDay
5           32          .00          4.31         6.41         22.88

(6 row(s) affected)
Author
12 Aug 2006 4:43 PM
Tibor Karaszi
Formatting of the values returned from SQL Server is performed by the client applications. The
client applications that comes with SQL Server (Query analyzer, SSMS etc) reads the meta-data to
determine what datatype each column is of and does a default presentation based on that. The tools
that come with SQL Server are not meant to be end-user tools. I suggest you format the values in the
client application that your end-users use...

Show quote
"Henry" <n**@il.com> wrote in message news:%23Vm5N4hvGHA.2232@TK2MSFTNGP05.phx.gbl...
> >
>> Allways for fixed scales go for Numeric data types.
>>
>> Declare @a float
>> set @a= 10.253612
>> select Convert(numeric(10,2),@a)
>>
>
> Well, I didn't chose the type, and I cannot change it.
>
> It actually help a little, but when the value is zero the it looks ugly
>
> .00 should at least be 0.00 right?
>
> regards
> Henry
>
>
> arname id          NoOfLogs    Sidste time  Sidste uge   Sidste mned Periode
> ----------------------------------------------------------------------------------------------------
> ----------- ----------- ------------ ------------ ------------ ------------
> Lan1_1_Lej_101A.X6991_P04_LastAccumDay 2           32          .00          85.90        173.17
> 586.19
> Lan1_1_Lej_101A.X5696_P41_J_LastAccumDay 6           32          .00          .00          1.00
> 221.00
> Lan1_1_Lej_101A.X5991_P05_LastAccumDay 3           32          .00          .47          .83
> 3.05
> Lan1_1_Lej_101A.X5991_P06_LastAccumDay 4           32          .00          .39          .89
> 3.27
> Lan1_1_Lej_101A.X5696_P41_Z_LastAccumDay 7           32          .00          .00          .40
> 34.38
> Lan1_1_Lej_101A.X5991_P07_LastAccumDay 5           32          .00          4.31         6.41
> 22.88
>
> (6 row(s) affected)
>
>
>

AddThis Social Bookmark Button