CSTX_Analysts
asked on
CAST or CONVERT: invalid attributes specified for type 'float'
When I run this code snippet:
select sum(cast(duration as float (2,2))/60)
from [172.31.10.11].cdr.dbo.Cal lDetailRec ord
I get the error in the thread title. This started happening after we upgraded to SQL 2005. Easy fix I am sure, just not quite sure of the new syntax
select sum(cast(duration as float (2,2))/60)
from [172.31.10.11].cdr.dbo.Cal
I get the error in the thread title. This started happening after we upgraded to SQL 2005. Easy fix I am sure, just not quite sure of the new syntax
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ok I have done the following. I ran the old code on a SQL2000 server. I also ran the code on a SQL2005 server , replacing "Float" with "Decimal". The result that is returned is slightly different between the two. I spoke with the original developer and they said that they used "Float" because it returned the most exact results so........ The question is can we make the returns from using "Decimal" or can I code it so that "Float" will still work?
Floating precision number data from: float [ ( n ) ] Floating point data is approximate
- 1.79E+308 to -2.23E-308, 0 and 2.23E-308 to 1.79E+308 depends on the value of n
Please understand the rounding errors with FLOAT([n]) and the storage size for your needs (n 1-24 = 7 digits =4 bytes, n 25-53 =15 digits = 8 bytes) depending on [n], but if the developers are using Float probably make sence use float for you n value Precision Storage size. The synonym for double precision for developers is float(53).
For decimal and numeric: Functionally equivalent:
decimal Fixed precision and scale numeric data from -10^38 +1 through 10^38 -1 numeric Fixed precision and scale numeric data from -10^38 +1 through 10^38 -1
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER