日期:2014-05-17  浏览次数:20511 次

存储过程运行成功,但调用时提示列明无效!

IF EXISTS (SELECT 1 FROM dbo.sysobjects WHERE ID = OBJECT_ID(N'[dbo].[zl_RptNotInvoiceSum3]') AND OBJECTPROPERTY(ID, N'IsProcedure') = 1)
DROP PROCEDURE [dbo].[zl_RptNotInvoiceSum3]
GO
CREATE PROCEDURE zl_RptNotInvoiceSum3
@CustID VARCHAR(50)='',----客户编号
@SODeliveryDateFrom VARCHAR(50),---送货日期从
@SODeliverDateTo VARCHAR(50),---送货日期到
--@SOInvoiceDate VARCHAR(50),--发票截止日期
@SalesMan VARCHAR(50)=''--业务员
WITH ENCRYPTION
AS
BEGIN
SET @CustID = RTRIM(LTRIM(ISNULL(@CustID,'')))
SET @SODeliveryDateFrom = RTRIM(LTRIM(ISNULL(@SODeliveryDateFrom ,'')))
SET @SODeliverDateTo = RTRIM(LTRIM(ISNULL(@SODeliverDateTo,'')))
SET @SalesMan = RTRIM(LTRIM(ISNULL(@SalesMan,'')))
CREATE TABLE #NotSOInvoiceSumAmount(
  InvoiceNote VARCHAR(50),
  CustID VARCHAR(50),
  CustName VARCHAR(200),
InvoiceQty REAL,
  SumInvoiceQty REAL,
--TotalArea FLOAT,--总面积
--TotalM2PerPiece REAL,--总金额
--TotalWeight REAL,
--TotalAmount REAL,
  InvoiceDate VARCHAR(50),
  AcceptDate VARCHAR(50),
  -- ActualDelDate VARCHAR(50),
SOCategory VARCHAR(50),--产品种类
  InvoiceAmountWithTax REAL,--含税金额
  SumInvoiceAmountWithTax REAL,--总含税金额
  InvoiceAmountWithoutTax REAL,--不含税金额
  SumInvoiceAmountWithoutTax REAL,--总不含税金额
  --TotalSingleActualArea DECIMAL(18,3),--单芯总面积
--TotalDoubleActualArea DECIMAL(18,3),---双芯总面积
  Salesman VARCHAR(50)
)


PRINT CONVERT (VARCHAR(50),GETDATE(),20)+'A'
 INSERT INTO #NotSOInvoiceSumAmount(

  InvoiceNote,  
  CustID,  
  CustName,
InvoiceQty,
  InvoiceDate,
  AcceptDate,
  -- ActualDelDate ,
  SOCategory,
  InvoiceAmountWithTax , 
  InvoiceAmountWithoutTax, 
  Salesman
   
)

select 


  A.InvoiceNote,  
  A.CustID,  
  A.CustName ,  
A.InvoiceQty,
A.InvoiceDate,
A.AcceptDate,
  --B.ActualDelDate,
  A.SOCategory,  
A.InvoiceAmountWithTax,
A.InvoiceAmountWithoutTax,
  A.Salesman

 
  FROM VSOInvoiceItem A WITH(NOLOCK)

where 
   
  ((A.InvoiceNote='') OR(ISNULL(A.InvoiceNote,'')='不开发票'))
  AND ((@CustID='') OR (A.CustID=@CustID))
AND ((@Salesman='') OR (A.Salesman=@Salesman))
  AND ((@SODeliveryDateFrom='')OR(A.AcceptDate>=@SODeliveryDateFrom))
  AND ((@SODeliverDateTo='')OR(A.AcceptDate<=@SODeliverDateTo))

update #NotSOInvoiceSumAmount
 
set
  SumInvoiceQty=InvoiceQty
from
  (
select