[SQL] 纯文本查看 复制代码
CREATE TRIGGER 插入新数据
ON jxcdata.dbo.spml
AFTER INSERT
AS BEGIN INSERT INTO
LYHS.dbo.ptype(UserCode,FullName,Name,Area,Standard,Unit1,preprice1,preprice4,preprice3,leveal,Unit2,UnitRate1,barcode,Type,Namepy)
SELECT SPBH,SPMC,SPMC,CD,GGXH,JLDW,CKJJ,CKSJ1,TwoPrice,MX,BZDW,BZSL,TMBH,CJBM,spjc2
FROM INSERTED WHERE spmc not like '%停用%' and spmc not like '%(换%' and mx=1
END
以上的是进销存插入新数据的时候,单个数据可以同步,
但是批量导入的时候,就一个都同步不过去,请教大侠,什么原因,是触发器代码的问题吗?
或者有没有更好的办法实现:A表增删改,B表都同步,(B表改动,A 不动)
再贴上在用的触发器,目前能用,有用过的大侠,看看有没问题:
[SQL] 纯文本查看 复制代码 CREATE TRIGGER 同步更新
ON jxcdata.dbo.spml
AFTER UPDATE
AS
update LYHS.dbo.ptype
SET
UserCode=SPBH,
FullName=SPMC,
Area=CD,
Standard=GGXH,
Unit1=JLDW,
preprice1=CKJJ,
preprice4=CKSJ1,
preprice3=TwoPrice,
leveal=MX,
Unit2=BZDW,
UnitRate1=BZSL,
barcode=TMBH,
Type=CJBM,
Namepy=spjc2
FROM
LYHS.dbo.ptype AS B,INSERTED AS A
WHERE B.UserCode=A.SPBH
[SQL] 纯文本查看 复制代码 CREATE TRIGGER 同步删除
ON [jxcdata].[dbo].[spml]
AFTER DELETE
AS BEGIN DELETE LYHS.dbo.ptype
WHERE
UserCode IN(
SELECT SPBH
FROM DELETED)
END |