我有一个返回公式格式的函数。它的某些部分----
if(CHARINDEX(@fieldname,@formula)<>0)
Begin
declare @previouschar char = SUBSTRING(@formula, CHARINDEX(@fieldname, @formula)-1, 1),
@nextchar char = SUBSTRING(@formula, CHARINDEX(@fieldname ,@formula)+len(@fieldname), 1)
if(@previouschar in('[',']','(',')','{','}','+','-','/','*')
and @nextchar in ('[',']','(',')','{','}','+','-','/','*'))
Begin
set @calFormula= replace(@calFormula,@fieldname,' case when FLD'+Convert(varchar,@flid)+' is null OR FLD'+Convert(varchar,@flid)+'='''' then 0.0 else Convert(decimal(18,'+ Convert(varchar,@decimalPlc) +'),FLD'+Convert(varchar,@flid)+' ) end ')
End
end
set @cnt1=@cnt1+1
End
set @calFormula= replace(@calFormula,'[','')
set @calFormula= replace(@calFormula,']','')
return @calFormula
我想在 Sql Server 关系数据库中实现 DAX 的 ISERROR 方法,该方法将检查输入的任何除数是否为零,然后在计算公式中分配 NULL。如何为此工作?SQL 中是否有类似 ISERROR 的替代方法?