В той же самой ситуации, а именно при создании из базы Access базы данных MS SQL, полностью удаляется из структуры следующее представление:
SELECT (SELECT Project FROM tblMain where ID = (SELECT ProjectID FROM tblSpecification where ID = tblRepayments.SpecificationID)) AS Project, (SELECT ProjectCategory FROM tblMain where ID = (SELECT ProjectID FROM tblSpecification where ID = tblRepayments.SpecificationID)) AS ProjectCategory, (SELECT ContractContragent FROM tblContracts where ID = (SELECT ContractID FROM tblSpecification where ID = tblRepayments.SpecificationID)) AS ContractContragent, 'Продукция' AS SubjectType, RepaymentType, RepaymentDeadline, RepaymentPartial, RepaymentCurrency, RepaymentPlan, RepaymentState, RepaymentDate, RepaymentAmount, IIf((RepaymentDate - RepaymentDeadline) > 0, RepaymentDate - RepaymentDeadline, NULL) AS RepaymentDelayCalc, IIf((RepaymentDate - RepaymentDeadline) > 0, RepaymentPlan - RepaymentAmount, NULL) AS RepaymentDeadlineCalc, RepaymentNotes, UserName, ConfirmedBy, ConfirmedDate, AddTime, SpecificationID, (SELECT ContractID FROM tblSpecification where ID = tblRepayments.SpecificationID) AS ContractID FROM tblRepayments
UNION ALL
SELECT (SELECT Project FROM tblMain where ID = (SELECT ProjectID FROM tblSpecification where ID = tblSupplies.SpecificationID)) AS Project, (SELECT ProjectCategory FROM tblMain where ID = (SELECT ProjectID FROM tblSpecification where ID = tblSupplies.SpecificationID)) AS ProjectCategory, (SELECT ContractContragent FROM tblContracts where ID = (SELECT ContractID FROM tblSpecification where ID = tblSupplies.SpecificationID)) AS ContractContragent, 'Транспортные услуги' AS SubjectType, NULL, RepaymentPlanned, PrepaidPercent + PaidFactPercent, 'RUR', AmountPlanned, SupplyStatus, RepaymentFact, SupplyAmount, IIf((RepaymentFact - RepaymentPlanned) > 0, RepaymentFact - RepaymentPlanned, NULL) AS RepaymentDelayCalc, IIf((RepaymentFact - RepaymentPlanned) > 0, AmountPlanned - SupplyAmount, NULL) AS RepaymentDeadlineCalc, SupplyNotes, UserName, NULL, NULL, AddTime, SpecificationID, (SELECT ContractID FROM tblSpecification where ID = tblSupplies.SpecificationID) AS ContractID FROM tblSupplies WHERE AmountPlanned IS NOT NULL OR SupplyAmount IS NOT NULL
UNION ALL
SELECT district (SELECT Project FROM tblMain where ID = (SELECT BoundID FROM tblContracts_tblMain where MainTableID = tblWorks.ContractID)) AS Project, (SELECT ProjectCategory FROM tblMain where ID = (SELECT BoundID FROM tblContracts_tblMain where MainTableID = tblWorks.ContractID)) AS ProjectCategory, (SELECT ContractContragent FROM tblContracts where ID = tblWorks.ContractID) AS ContractContragent, 'Работы' AS SubjectType, NULL, WorkDeadline, PrepaidPercent + PaidFactPercent, 'RUR', AmountFact, WorkStatus, RepaymentDate, WorkAmount, IIf((RepaymentDate - WorkDeadline) > 0, RepaymentDate - WorkDeadline, NULL) AS RepaymentDelayCalc, IIf((RepaymentDate - WorkDeadline) > 0, AmountFact - WorkAmount, NULL) AS RepaymentDeadlineCalc, WorkNotes, UserName, NULL, NULL, AddTime, NULL, ContractID FROM tblWorks WHERE AmountPlanned IS NOT NULL OR AmountFact IS NOT NULL OR WorkAmount IS NOT NULL
Подскажите в какую сторону копать, т.к. в Access все работает.
IIF на CASE WHEN... THEN... ELSE... END менял. Не помогло. Пациент мертв.
|