|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
limit the number of decimals on a float fieldHi
Does anyone know how to limit the numbers of decimals after the point in a query? cheers Henry 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 > > Well, I didn't chose the type, and I cannot change it.> Allways for fixed scales go for Numeric data types. > > Declare @a float > set @a= 10.253612 > select Convert(numeric(10,2),@a) > 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) 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 quoteTibor Karaszi, SQL Server MVP http://www.karaszi.com/sqlserver/default.asp http://www.solidqualitylearning.com/ "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) > > > |
|||||||||||||||||||||||