tsql track all changes related to one table in the database -


i have transactional db, table t1 pk , want track changes occurred in tables related t1. thought of using cdc, able browse existing cdc tables see ones have changes related t1 proved bit of challenge. easy changes tables connected t1 directly, no matter level (e.g. tn has fk tn-1, has fk tn-2 etc has fk t2 has fk t1). don't know how create script changes tables not connected directly, e.g. t6 has fk t5 has fk t4, t3 has fk t4 , t2, , t2 has fk t1 (1st or through multiple levels), t6 connects t1 in end, not through 1 way type of relationship.

does have idea on how this?

a specific example: have table contracts has column contractid , other columns , want create history table holds changes related contractid, have columns contractid, oldvalue, newvalue. these changes can come a) tables have fk contracts.contractid, example tblperiod(periodid, contractid, etc), b) tables reference contracts.contractid through multiple relationships, e.g. tblsubperiod (subperiodid, periodid, etc) references tblperiod references contracts.contractid or c) tables can't connected contracts through fk keys, e.g. tblcomissionshare has fk tblcommission, tblsubperiod has fk tblcommission , know above, tblsubperiod has fk tblperiod has fk contracts. change in table tblcommissionshare should appear in history table. querying cdc tables need dynamic query generates joins between table contracts , other tables relate described above can populate history table.


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -