I am having two databases. When a new customer record is added into fDebtor table in database ABC, a new record should be appended in fDebtor table in database DEF as well.
Can some one help me to write a stored procedure for this?
there should be a validation to check whether the record is already exists in next table also
create trigger TRG_Insert_fDebtor on ABC.fDebtor
ON AFTER Insert
as
begin
SET NOCOUNT ON;
--- checking for the record exist in the DEF database
IF (select count(*) from DEF.fDebtor where exists(select * from inserted)) > 0
begin
----- insert record in your other database DEF
insert into DEF.fDebtor values ()
end
end
Try trigger like that made changes as you need that's just approach you can use.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.