| Author |
Topic  |
|
|
ibbo14
Starting Member
Australia
7 Posts |
Posted - 02/07/2013 : 21:15:42
|
Hi,
I was hoping that someone would have a solution to a problem that I have just encountered. I am migrating data from one system to another, and in the source DB, the decimal type data is specified as real. The destination DB is using float. I have been using select insert statements, and the real data type fields were appearing as rounded. After completing the migration I realized that this is not the case.
An example: It appears in the source db using the real data type as -58.6
When using float it appears as: -58.5999984741211
Is there a way to fix this without remigrating the data. The catch is that the number of decimal places can vary.
Thanks! |
|
|
visakh16
Very Important crosS Applying yaK Herder
India
47023 Posts |
Posted - 02/07/2013 : 23:15:19
|
if you want values up to definite decimal place only stored in table, you need to use fixed numerical datatypes like Numeric of Decimal. float,real are approximate datatypes.
------------------------------------------------------------------------------------------------------ SQL Server MVP http://visakhm.blogspot.com/
|
 |
|
|
ibbo14
Starting Member
Australia
7 Posts |
Posted - 02/08/2013 : 00:01:10
|
Thanks for the response visakh
In my case the number of decimal places can vary, this is why I chose float as the destination data type. So rounding may not be an option.
I have been digging deeper and have tried the approach of converting the real value to varchar and then to float. It seems to work, but something is telling me not to trust this.
Or am I being a bit too cautious? |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
India
47023 Posts |
Posted - 02/08/2013 : 03:25:42
|
quote: Originally posted by ibbo14
Thanks for the response visakh
In my case the number of decimal places can vary, this is why I chose float as the destination data type. So rounding may not be an option.
I have been digging deeper and have tried the approach of converting the real value to varchar and then to float. It seems to work, but something is telling me not to trust this.
Or am I being a bit too cautious?
in that case you can use round where value will be rounded to required decimal place
------------------------------------------------------------------------------------------------------ SQL Server MVP http://visakhm.blogspot.com/
|
 |
|
| |
Topic  |
|