Skip to content

Possible misunderstanding of purpose of ISNUMERIC() #4

Open
@brianary

Description

@brianary

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions