gpt4 book ai didi

tsql - sql如何计算ISNUMERIC(ISNULL(VALUE, 'blah' ))

转载 作者:行者123 更新时间:2023-12-01 12:51:40 32 4
gpt4 key购买 nike

我的假设是,如果该值是数字(在非数字范围内),它将返回 true,但如果 ISNULL 返回 'blah'<,它将返回 FALSE/。看来我的假设不对...

我正在以下列方式使用它

case when ISNULL(ISNUMERIC(c.npinumber), 'blah') = 1
then c.NPiNUmber
else 'not valid: ' + c.NpiNumber
end as npi

最佳答案

以 Dhruvesh 的回答为基础,

case
when ISNUMERIC(c.npinumber) = 1 then c.NPiNUmber
else 'not valid: ' + c.NpiNumber
end as npi

只要 NpiNumber 为 NULL,就会产生 NULL。原因是 NULL + 任何字符串仍然会返回 NULL。解决方案是简单地使用 COALESCE 函数

case
when ISNUMERIC(c.npinumber) = 1 then c.NPiNUmber
else 'not valid: ' + COALESCE(c.NpiNumber, 'NULL VALUE')
end as npi

关于tsql - sql如何计算ISNUMERIC(ISNULL(VALUE, 'blah' )),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12048219/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com