Find non-integer values ​​in float field

I find it difficult to find a way to write a query that returns all non-integer numbers in the float column in SQL Server 2005/8.

I have a floating point field where most of the data in it is integers, but I would like to look at strings where the values ​​actually contain a decimal value. The first thing I tried was module 1, but the% operator does not work with float values.

Thank you for your help!

+3
source share
4 answers

Do you just want strings with a decimal point to be in it?

select field
from table
where field like '%.%'
+4
source

I don't know the exact syntax of MSSQL, however you can try something like this (pseudo code)

SELECT ... FROM tbl_name WHERE col_name != CAST(col_name AS INTEGER)
+4
source

- :

SELECT * 
FROM MyTable
WHERE (CONVERT(INT, floatField) - floatField) <> 0
+2

:

SELECT * FROM tbl WHERE col != ROUND(col)
+2

Source: https://habr.com/ru/post/1793646/


All Articles