sql server database synchronization add identifiers

I am here need a database using the data timing synchronization job to another database, but the need to record additional identifier plus a database, for example, this data is deleted in the original data is identified as delete, the new logo is new, what is it good idea? Ask you Great God!

As upstairs said, while the original database set as the primary key id, and id should be self-appreciation. I do not know what you said two databases are not in the same server, if it is, use the trigger on it.
Assumption that the original library tb1, another library tb2, the tag field is mark, delete the mark 'del', the new tag 'new', in other cases the update, I personally think that the original data set 'del', the new data is' new ', another database id should be set to a non-clustered index, depending on your own actual situation to be
the Create the Trigger trtb1 oN TB1 for INSERT, Update, the Delete AS
IF EXISTS (0 from the SELECT inserted the) and EXISTS (deleted from the SELECT 0) Update Mark TB2 SET = the begin 'del' WHERE ID in (SELECT ID from deleted); INSERT INTO TB2 (..., Mark) SELECT ..., 'new new' from inserted The End
IF (INSERT) INSERT INTO TB2 (.. ., Mark) the SELECT ..., 'new new' from inserted The
IF (the Delete) ...

If the Job have to use, add, delete operations are:
INSERT INTO TB2 (..., Mark) SELECT ..., 'new new' WHERE ID from TB1> (SELECT max (ID) from TB2)
Update Mark TB2 SET = 'del' where id in (select id from tb2 where mark <> 'del' except select id from tb1 where id <(select max (id) from tb2))
but the situation will be difficult to update, these are my views

Guess you like

Origin www.cnblogs.com/SyncNavigator8-4-1/p/10974311.html