解决方案: |
可以把正确的视图复制过来,重新创建,具体的脚本如附件。
drop view Ap_SalBillCust
go
create view Ap_SalBillCust as SELECT Customer.cCCCode AS cDWCCode,CustomerClass.cCCName as cDWCName,Customer.cDCCode AS cDWDCode,DistrictClass.cDCName,CASE WHEN Customer.cCusName<>‘‘ THEN Customer.cCusName ELSE Customer.cCusAbbName END AS cDWName,Customer.cCusPPerson AS cHPsnCode,Person_1.cPersonName as cHPersonName,Customer.cCusDepart AS cHDptCode,Department_1.cDepName as cHDepName,Customer.cCusHeadCode AS cHDWCode,
CASE WHEN Customer_1.cCusName<>‘‘ THEN Customer_1.cCusName ELSE Customer_1.cCusAbbName END AS cHDwName,Customer.iCusCreLine AS iCreLine, Department.cDepName, Person.cPersonName, Inventory.cInvName,Inventory.cInvCCode,InventoryClass.cInvCName,
Ap_VouchType.cTypeName,dDate+IsNull(PayCondition.iPayCreDays,0) AS dExpireDate,dDate+IsNull(PayCondition_1.iPayCreDays,0) AS dExpireDate_DW,dDate+IsNull(PayCondition.iPayFaDays,0)AS dFaDate,PayCondition.cPayName, SaleBillVouch.cCusCode AS cDWCode, SaleBillVouch.cDepCode AS cDeptCode, SaleBillVouch.cPersonCode AS cPerson,SaleBillVouch.cMemo AS cDigest,
SaleBillVouch.cInvalider as cInvalider,SaleBillVouch.cChecker,SaleBillVouch.dDate AS dVouchDate, SaleBillVouch.cVouchType, SaleBillVouch.cSBVCode AS cVouchID, SaleBillVouch.cMaker, SaleBillVouch.cVerifier AS cCheckMan, SaleBillVouch.cPayCode, SaleBillVouch.cexch_name, SaleBillVouch.iExchRate, SaleBillVouchs.cInvCode, SaleBillVouchs.iNatSum AS iAmount, SaleBillVouchs.iSum AS iAmount_f,
SaleBillVouchs.iMoneySum AS iFmount,SaleBillVouchs.iExchSum AS iFmount_f, SaleBillVouchs.iQuantity AS iAmount_s, SaleBillVouchs.iNatUnitPrice AS iprice, SaleBillVouchs.iNatTax AS ino_id,1-bReturnFlag as bd_c,bpayment,bFirst,cClue FROM ((((((((((((SaleBillVouch LEFT JOIN Ap_VouchType ON SaleBillVouch.cVouchType = Ap_VouchType.cTypeCode) LEFT JOIN Customer ON SaleBillVouch.cCusCode = Customer.cCusCode)
LEFT JOIN Department ON SaleBillVouch.cDepCode = Department.cDepCode) LEFT JOIN Person ON SaleBillVouch.cPersonCode = Person.cPersonCode) LEFT JOIN PayCondition ON SaleBillVouch.cPayCode = PayCondition.cPayCode) INNER JOIN (SaleBillVouchs LEFT JOIN Inventory ON SaleBillVouchs.cInvCode = Inventory.cInvCode) ON SaleBillVouch.SBVID = SaleBillVouchs.SBVID)
LEFT JOIN PayCondition AS PayCondition_1 ON Customer.cCusPayCond = PayCondition_1.cPayCode) LEFT JOIN CustomerClass ON Customer.cCCCode=CustomerClass.cCCCode) LEFT JOIN Customer as Customer_1 ON Customer.cCusHeadCode=Customer_1.cCusCode) LEFT JOIN DistrictClass ON Customer.cDCCode=DistrictClass.cDCCode) LEFT JOIN Department as Department_1 ON Customer.cCusDepart=Department_1.cDepCode) LEFT JOIN Person as Person_1 ON Customer.cCusPPerson=Person_1.cPersonCode) LEFT JOIN InventoryClass ON Inventory.cInvCCode=InventoryClass.cInvCCode
Where cChecker Is Not Null And isnull(cInvalider,‘‘)=‘‘
go
drop view Ap_PurBillVend
go
CREATE VIEW Ap_PurBillVend as SELECT Vendor.cVCCode AS cDWCCode,VendorClass.cVCName as cDWCName,Vendor.cDCCode AS cDWDCode,DistrictClass.cDCName,
Case When Vendor.cVenName<>‘‘ Then Vendor.cVenName Else Vendor.cVenAbbName End AS cDWName,
Vendor.cVenPPerson AS cHPsnCode,Person_1.cPersonName as cHPersonName,Vendor.cVenDepart AS cHDptCode,Department_1.cDepName as cHDepName,
Vendor.cVenHeadCode AS cHDWCode,CASE WHEN Vendor_1.cVenName<>‘‘ THEN Vendor_1.cVenName ELSE Vendor_1.cVenAbbName END as cHDWName,
Vendor.iVenCreLine AS iCreLine,Department.cDepName, Person.cPersonName, Inventory.cInvName, Inventory.cInvCCode,InventoryClass.cInvCName,
dPBVDate+IsNull(PayCondition.iPayCreDays,0) AS dExpireDate,dPBVDate+IsNull(PayCondition_1.iPayCreDays,0) AS dExpireDate_DW,
dPBVDate+IsNull(PayCondition.iPayFaDays,0)AS dFaDate,Ap_VouchType.cTypeName,
PayCondition.cPayName,PurBillVouch.cUnitCode AS cDWCode, PurBillVouch.cDepCode AS cDeptCode, PurBillVouch.cPersonCode AS cPerson,PurBillVouch.cPBVMemo AS cDigest,
PurBillVouch.dPBVDate AS dVouchDate, PurBillVouch.cPBVBillType AS cVouchType, PurBillVouch.cPBVCode AS cVouchID, PurBillVouch.cPBVMaker,
PurBillVouch.cPBVVerifier AS cCheckMan, PurBillVouch.cPayCode, PurBillVouch.cexch_name, PurBillVouch.cExchRate AS iExchRate,
PurBillVouchs.cInvCode, PurBillVouchs.iSum AS iAmount, PurBillVouchs.iOriSum AS iAmount_f,PurBillVouchs.iTotal AS iFmount,
PurBillVouchs.iOriTotal AS iFmount_f, PurBillVouchs.iPBVQuantity AS iAmount_s, PurBillVouchs.iCost AS iprice, PurBillVouchs.iTaxPrice AS ino_id,PurBillVouch.dSDate,
bNegative as bd_c,bpayment,bFirst,bOriginal,cClue,iNetLock
FROM ((((((((((((PurBillVouch LEFT JOIN Ap_VouchType ON PurBillVouch.cPBVBillType = Ap_VouchType.cTypeCode) LEFT JOIN Vendor ON PurBillVouch.cUnitCode = Vendor.cVenCode)
LEFT JOIN Department ON PurBillVouch.cDepCode = Department.cDepCode) LEFT JOIN Person ON PurBillVouch.cPersonCode = Person.cPersonCode)
LEFT JOIN PayCondition ON PurBillVouch.cPayCode = PayCondition.cPayCode) INNER JOIN (PurBillVouchs LEFT JOIN Inventory ON PurBillVouchs.cInvCode = Inventory.cInvCode)
ON PurBillVouch.PBVID = PurBillVouchs.PBVID) LEFT JOIN PayCondition AS PayCondition_1 ON Vendor.cVenPayCond = PayCondition_1.cPayCode) LEFT JOIN
VendorClass ON Vendor.cVCCode=VendorClass.cVCCode) LEFT JOIN Vendor as Vendor_1 ON Vendor.cVenHeadCode=Vendor_1.cVenCode) LEFT JOIN DistrictClass ON
Vendor.cDCCode=DistrictClass.cDCCode) LEFT JOIN Department as Department_1 ON Vendor.cVenDepart=Department_1.cDepCode) LEFT JOIN Person as Person_1 ON
Vendor.cVenPPerson=Person_1.cPersonCode) LEFT JOIN InventoryClass ON Inventory.cInvCCode=InventoryClass.cInvCCode
|