Efficient ISNUMERIC() replacements on SQL Server?

后端 未结 11 2043
失恋的感觉
失恋的感觉 2020-11-27 06:02

So I just spent 5 hours troubleshooting a problem which turned out to be due not only to the old unreliable ISNUMERIC but it looks like my problem only appears

11条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-27 06:50

    SQL 2012 onwards, you can use TRY_PARSE() function instead of ISNUMERIC().

    SELECT
     TRY_PARSE('123' as int) as '123'
    ,TRY_PARSE('abc' as int) as 'abc'
    

提交回复
热议问题