解决方案: |
此处有两种解决方法:
--查询采购发票主表中科目编码在科目表中没有的记录
select PurBillVouch.cHeadCode
from PurBillVouch left join code on PurBillVouch.cHeadCode=code.ccode
where code.ccode is null
and PurBillVouch.cHeadCode is not null
1、使用以下SQL语句删除采购发票中的错误记录。
--删除对应的发票
delete
from PurBillVouchs
where pbvid = in (
select PurBillVouch.pbvid
from PurBillVouch left join code on PurBillVouch.cHeadCode=code.ccode
where code.ccode is null
and PurBillVouch.cHeadCode is not null
)
delete
from PurBillVouch
where pbvid = in (
select PurBillVouch.pbvid
from PurBillVouch left join code on PurBillVouch.cHeadCode=code.ccode
where code.ccode is null
and PurBillVouch.cHeadCode is not null
)
2、在科目表(code)中加入缺少的科目。
具体使用那种方法请根据客户实际情况使用。
|