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.CallDetailRecord

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
CSTX_AnalystsAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ErnariashCommented:
error on float(2,2)
you could do decimai(2,2) or numeric(2,2)

select sum(cast(duration as float)/60)
                        from [172.31.10.11].cdr.dbo.CallDetailRecord

Open in new window

0
CSTX_AnalystsAuthor Commented:
That is actually what I thought about doing. I just wanted to make sure there were no hidden "gotchas" going from using float to using decimal. From what I can tell the results are the same.
0
CSTX_AnalystsAuthor Commented:
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?
0
ErnariashCommented:

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  

 
 
0
CSTX_AnalystsAuthor Commented:
I ran the query using "Float" instead of "Float (2,2). Compared the results between the two versions and they were the same.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.