解决方案: |
先通过以下语句修正以前的产成本入库单设有录入成本对象;update rdrecords set cName=fItemss99.citemname,cItemCode=fItemss99.citemname,cItem_class='99',cItemCName='成本对象' from fItemss99
where rdrecords.cinvcode=fItemss99.invcode and --rdrecords.cinvcode='4111028'
rdrecords.id in (select id from rdrecord where crdcode in ('102','103'))
再在Rdrecords表加入触发器自动在增、改产成品入库单时填入成本对象,不改变客户现有的录单习惯;
CREATE TRIGGER [RdRecords_INS_UP] ON [dbo].[RdRecords] WITH ENCRYPTION
FOR INSERT, UPDATE
AS
UPDATE RdRecords SET cName=fItemss99.citemname,cItemCode=fItemss99.citemname,cItem_class='99',cItemCName='成本对象' from fItemss99
where rdrecords.cinvcode=fItemss99.invcode and rdrecords.id in (select id from rdrecord where crdcode in ('102','103')) AND rdrecords.id in (select id from inserted)
|