Open
Description
The purpose of ISNUMERIC()
is to determine whether a character field/column will throw errors when cast to a numeric type, not whether a field/column is a valid SSN or CC#, e.g. It doesn't indiscriminately accept -
or +
or even E
, but it does accept -2.1E-3
because cast('-2.1E-3' as float)
works and +$.99
because cast('+$.99' as money)
works.
This is particularly helpful for migration scripts when changing the datatype of a column from character to numeric, and couldn't be easily accomplished to accept a wide range of legal numeric literals without
numcolumn = case ISNUMERIC(charcolumn) when 1 then cast(charcolumn as float) end
Filtering non-digit chars is the job of not like '[^0-9]'
.
Metadata
Metadata
Assignees
Labels
No labels