SQL Server转换在其他服务器上失败



我有一个select语句,它的Isnumeric转换在一台服务器上失败,在另一台服务器中运行良好。

两台服务器都在使用SQL Server 2012。该数据库是第二台服务器上的副本。

错误:

将varchar值"700.00"转换为数据类型int 时转换失败

主选择实际上不返回任何行。

voidOrDenied = (case when isnumeric(c.reasonpending) = 1 and 
cast(left(c.reasonpending, charindex(',', c.reasonpending+',')-1) as int)
between 1 and 25 then 'Void'
when c.reasonpending like '%void%' then 'Void'
else 'Denied' end),

第二台服务器上会有什么不同?

使用try_cast():

(case when try_cast(left(c.reasonpending, charindex(',', c.reasonpending+',')-1) as int) between 1 and 25
then 'Void'
when c.reasonpending like '%void%' then 'Void'
else 'Denied'
end)

最新更新