Log in  ::  Register  ::  Not logged in

 Recent PostsRecent Posts Popular TopicsPopular Topics
 Home Search Members Calendar Who's On

 Difference between Numeric and Float Rate Topic Display Mode Topic Options
Author
 Message
 Posted Friday, June 27, 2008 4:29 AM
 Valued Member Group: General Forum Members Last Login: Tuesday, December 8, 2009 10:24 AM Points: 63, Visits: 61
 Hi all,I am getting error message while trying to insert Float datatype values into Numeric datatype column. How can we avoid this ?Also, please tell me what is the difference between float and numeric datatypes.Thanks,Ezhilan
Post #524869
 Posted Friday, June 27, 2008 12:37 PM
 SSChampion Group: General Forum Members Last Login: Monday, August 29, 2016 1:09 PM Points: 13,999, Visits: 9,728
 Numeric (also called Decimal) has a defined precision and scale. Float just uses defaults for that.You can end up with overflow errors because of this.For example, if you define a column/variable as Numeric(10,8), you are defining it with a total of 10 digits, and 8 of them are the right of the decimal place. If you try to insert any number >= 100 into this, it will give an error. A Float data type can handle those numbers quite easily, so that conversion will give you errors. (It can go the other way as well, if you have a float with 10 digits to the right of the decimal, and put them in a numeric with only 8, it will cut off the last two digits. Won't give an error, but will drop the precision.)That's probably what's happening to you. Many people define numeric (decimal) data types for the largest precision they think will happen, and don't realize they are reducing the number of allowed digits to the left of the decimal. - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETCProperty of The Thread"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
Post #525280

 Permissions