CREATE trigger TRI_UPDATE
on tblchenji
after insert,update
as
declare @cid int,@cfid int, @cfen int
select @cfid=cfid,@cid=cid from tblfen where cfen> fmin and cfen<fmax
if @cfid is not null and @cid is null
begin
update tblchenji set cfid=@cfid where cid=@cid
end