1

How can I check if the value is numeric? I tried is numeric but it is returning an error that the function is not found.

Example:

select *isnumeric*("abc") // returns 0 or false
select *isnumeric*("123") // returns 1 or true
Cœur
  • 37,241
  • 25
  • 195
  • 267
Ray
  • 627
  • 1
  • 7
  • 19

1 Answers1

5

A reasonable method is to look for non-digits:

select (case when str like '%[^0-9]%' then 0 else 1 end)

This looks for strings of digits. You can extend it to support negative signs, decimal points, and exponential representation if those are needed.

Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786