需要Sql查询,如果可能,将值转换为int,如果不可能,则将value设置为0。
SELECT IIF((isnumeric('11961630')),TRY_PARSE('11961630' as int), 0) => it should return 11961630
SELECT IIF((isnumeric('CH11961630')),TRY_PARSE('CH11961630' as int), 0) => it should return 0
最佳答案
select isnull(try_parse('42' as int), 0) -- returns 42
select isnull(try_parse('fred' as int), 0) -- returns 0
关于sql - SQL如果可能,将值转换为int,如果不可能,则将值设置为0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58029544/