Sql Server ISERROR功能

时间:2013-11-19 12:00:59

标签: sql-server dax

我有一个函数返回它的formula.some部分的格式----

  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?

1 个答案:

答案 0 :(得分:0)

不确定

IsError(1/0)将返回true(因为存在错误)

IsError(1/1)将返回false(无错误)。

Technet