I’m dealing with a legacy system where I need to identify some bad records based on a column with a data type of Float.
Good records have a value of…
1
2
1.01
2.01
Bad records are anything such as..
1.009999999999999
2.003423785643000
3.009999990463260
I’ve tried a number of select statements where I Convert to Decimal and cast to a varchar and use the LEN() function but this don’t seem to work as the good records that are 1.01 become 1.0100000000000000
–Edit
I’m a little closer now as I have discovered I can do (Weight * 100) and all of the good records become whole number values such as 101,201,265,301,500, etc…
and bad ones such as 2.00999999046326 become 200.999999046326
This works on my SQL Server 2005 DB:
Result:
4
In fact, it even lets me skip the explicit varchar cast if I want to:
Result:
5
Update: First of all, I still needed the cast to varchar. Thinking otherwise was wrong. That said, I had this all working using strings and was about to post how. Then you I your update on mulitpling by 100 and realized that was the way to go. So here’s my code for testing both ways: