Why it does not work. When QTY is a numeric column, when you show it or implicitly convert it to varchar (LIKE does it implicitly), ALL numbers will be converted to the same number of decimal places.
Consider this SQL statement
with TBL(qty) as (select 1.1 union all select 3) SELECT li.QTY FROM TBL LI WHERE li.QTY like '%.%'
Exit
1.1 3.0 << this contains "." even if it does not need to
Copy it to bigint and it will drop any decimal numbers and then compare it again.
SELECT li.QTY FROM TBL LI WHERE li.QTY <> CAST(qty as bigint)
If you MUST use LIKE (or just for the show ..)
SELECT li.QTY, CONVERT(varchar, li.qty) FROM TBL LI WHERE li.QTY LIKE '%.%[^0]%'
RichardTheKiwi
source share