Is there an easy way to get if string is an integer number (consists only of digits) in MS SQL 2005?
Thank you for your help.
Even though the original poster was referring to SQL 2005, I found in 2008 r2 a straight where isnumeric(string)
resulted in an error 4145 non-boolean type. To resolve this use:where isnumeric(string) = 1
The function ISNUMERIC returns whether a string is numeric, but will return true for non-integers.
So you could use:
WHERE ISNUMERIC(str) AND str NOT LIKE '%.%' AND str NOT LIKE '%e%' AND str NOT LIKE '%-%'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With