0

I have this table in my SQL Server database

tblImage

The type of Gisx and Gisy columns is FLOAT.

When I want to select from this table like this :

SELECT * 
FROM TblImage  
WHERE GisX = 57.2938107

everything is fine, but when the digits after the point are more than 7 digits, the result of selection is going to be nothing while there is such field in the table:

SELECT * 
FROM TblImage  
WHERE GisX = 38.0752152407368

I know maybe it is because of the problem in float but is there any way to fix the problem?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
atabrizi
  • 908
  • 1
  • 13
  • 29
  • @atabrizi you retrieve result based on exact match either it is 7 or 5 digit after decimal. If you get other result either it is exact matched or not then you can apply >= or <=. Please check the url https://dbfiddle.uk/?rdbms=sqlserver_2017&fiddle=e98bf8ceeb3cb048b36ae471fdf2b4db – Rahul Biswas Sep 25 '21 at 07:17
  • @RahulBiswas I can not use >= or <= because I want exact match – atabrizi Sep 25 '21 at 07:26
  • @GSerg . how can I fix the problem. is it possible or I should change the tpe? – atabrizi Sep 25 '21 at 07:28
  • 5
    It is not a problem, it is how floating point numbers are designed. If you want exact matches, use `numeric`. – GSerg Sep 25 '21 at 07:33
  • 1
    *because I want exact match* - but you're using a data type that stores *approximations*, so yes you need to use decimal / numeric. – Stu Sep 25 '21 at 08:57

0 Answers0