觸發本觸發器的條件是:插入的語句的projectid(企業編號)>0而且cdxm(長貸項目)=‘借款金額’時,同時在本表中插入一條projectid和marketid、cdje(長貸金額)相同,marketyear=插入的marketyear(發生年份)+插入的zq(帳期),長貸項目爲‘應還金額’的數據記錄。
Code
if
exists(
select projectid
from inserted
where projectid>0)
begin
insert
into cd
select projectid,marketid,
convert(
int,marketyear)+
convert(
int,zq),
'應還金額',cdje,0
from inserted
where cdxm=
'借款金額'
and projectid>0
end