我的存储过程执行时发生如下错误,请问可能是什么问题?
Executed as user: sa. ...gregate or other SET operation. [SQLSTATE 01003] (Message 8153)  Warning: Null value is eliminated by an aggregate or other SET operation. [SQLSTATE 01003] (Message 8153)  Warning: Null value is eliminated by an aggregate or other SET operation. [SQLSTATE 01003] (Message 8153)  Warning: Null value is eliminated by an aggregate or other SET operation. [SQLSTATE 01003] (Message 8153)  Warning: Null value is eliminated by an aggregate or other SET operation. [SQLSTATE 01003] (Message 8153)  Warning: Null value is eliminated by an aggregate or other SET operation. [SQLSTATE 01003] (Message 8153)  Warning: Null value is eliminated by an aggregate or other SET operation. [SQLSTATE 01003] (Message 8153)  Warning: Null value is eliminated by an aggregate or other SET operation. [SQLSTATE 01003] (Message 8153)  Warning: Null value is eliminated by an aggregate or other SET operation. [SQLSTATE 01003] (Message 8153)  Warning: Null value is eliminated by an aggregate or ot...  The step failed.

解决方案 »

  1.   

    对聚合函数来说,如果空值可能导致错误结果,最好使用ISNULL函数
      

  2.   

    一般来说,这个错误不要紧的啊?sum(isnull(数量,0))
      

  3.   


    CREATE PROCEDURE dt_generateTotalreports
    /*
    (
    @parameter1 datatype = default value,
    @parameter2 datatype OUTPUT
    )
    */
    @reportDate datetime,
    @carType varchar(8)

    AS
    /* SET NOCOUNT ON */
    Declare 
    @plan_csc_total numeric,
    @fact_csc_total numeric,
    @plan_otssend_total numeric,
    @fact_otssend_total numeric,
    @plan_otsauthor_total numeric,
    @fact_otsauthor_total numeric,
    @plan_empbauthor_total numeric,
    @fact_empbauthor_total numeric,
    @plan_accp_total numeric,
    @fact_accp_total numeric,
    @fact_qatry_total numeric,
            @fact_empbauthor_total_1 numeric,
            @fact_empbauthor_total_3 numeric,
            @fact_empbauthor_total_6 numeric
    set @plan_csc_total = (select count(a.Part_ID) from Part_Info a,(SELECT DISTINCT Part_num, speccode FROM SpecCode_Part) b 
    where convert(char(10),a.CSC_Date,120) = convert(char(10),@reportDate,120) 
    and a.Part_Num = b.Part_Num and b.SpecCode=@carType and (a.PartFlowType <> 'Copy' or a.PartFlowType is null)) 
    set @fact_csc_total = (select count(a.Part_ID) from CSC_Conference a,Part_Info b,(SELECT DISTINCT Part_num, speccode FROM SpecCode_Part) c 
    where convert(char(10),a.cnfTime,120)= convert(char(10),@reportDate,120) and a.Part_ID = b.Part_ID 
    and b.Part_Num = c.Part_Num and c.SpecCode=@carType and (b.PartFlowType <> 'Copy' or b.PartFlowType is null))
    ... ...
            ... ... set @plan_csc_total = @plan_csc_total + (select count(a.Part_ID) from Part_Info a,(SELECT DISTINCT Part_num, speccode FROM SpecCode_Part) b,Part_Info c
    where convert(char(10),c.CSC_Date,120) = convert(char(10),@reportDate,120) and a.Part_FlowID = c.Part_FlowID and a.Part_ID <> c.Part_ID
    and a.Part_Num = b.Part_Num and b.SpecCode=@carType and a.PartFlowType = 'Copy') 
    set @fact_csc_total = @fact_csc_total + (select count(a.Part_ID) from CSC_Conference a,Part_Info b,(SELECT DISTINCT Part_num, speccode FROM SpecCode_Part) c,Part_Info d
    where convert(char(10),a.cnfTime,120)= convert(char(10),@reportDate,120) and a.Part_ID = b.Part_ID and b.Part_FlowID = d.Part_FlowID and b.Part_ID <> d.Part_ID
    and b.Part_Num = c.Part_Num and c.SpecCode=@carType and b.PartFlowType = 'Copy')
    set @plan_otssend_total = @plan_otssend_total + (select count(a.Part_Comp_ID) from Schedule_Table a,Comp_part_Info b,Part_Info c,(SELECT DISTINCT Part_num, speccode FROM SpecCode_Part) d,Part_Info e 
    where convert(char(10),a.PlanSend_Time,120) = convert(char(10),@reportDate,120) and a.Part_Comp_ID = b.Part_Comp_ID and c.Part_FlowID = e.Part_FlowID and c.Part_ID <> e.Part_ID
    and b.Part_ID = c.Part_ID and c.Part_Num = d.Part_Num and d.SpecCode=@carType and c.PartFlowType = 'Copy')
    ....
            .... insert into TotalReport values(@reportDate,@carType,isnull(@plan_csc_total,0),isnull(@fact_csc_total,0),
    isnull(@plan_otssend_total,0),isnull(@fact_otssend_total,0),isnull(@plan_otsauthor_total,0),
    isnull(@fact_otsauthor_total,0),isnull(@plan_empbauthor_total,0),isnull(@fact_empbauthor_total,0),
    isnull(@plan_accp_total,0),isnull(@fact_accp_total,0),isnull(@fact_qatry_total,0),isnull(@fact_empbauthor_total_1,0),isnull(@fact_empbauthor_total_3,0),isnull(@fact_empbauthor_total_6,0))

    RETURN
    GO
      

  4.   

    试试在存储过程的头部加上SET ANSI_NULLS OFF