How Does the Change Data Capture Feature in SQL Server Function

 In 2005, Microsoft introduced the “after date”, “after delete”, and “after insert” features in SQL Server that came to be known as SQL Server Change Data Capture. But it was not before 2008 that a new and improved version was launched that is still in vogue today.  

How does SQL Server Change Data Capture function? Primarily, it monitors and captures changes made to the tables in the SQL Server database without using any additional applications or programs. Microsoft, till 2016, offered this feature only in the high-end Enterprise edition but later became standard across all editions of SQL Server.

Apart from the core function of SQL Server Change Data Capture which is to track all Insert, Update, and Delete changes, the feature also records changes in a mirrored table with the same column structure as the source. One record is written by SQL Server for every Insert and Delete value while two records are written for every Update statement – data before the change and one after.


The following data is present in SQL Server Change Data Capture.

·        __$start_lsn and __$end_lsn that show the commit log sequence number (LSN) assigned by the SQL Server Engine to the recorded change

·        __$seqval that shows the order of that change related to other changes in the same transaction, __$operation that shows the operation type of the change, where 1 = delete, 2 = insert, 3 = update (before change), and 4 = update (after change)

·        __$update_mask that is a bitmask defined for each captured column, identifying the updating columns

This is how SQL Server Change Data Capture functions

Comments

Popular posts from this blog

The Unique Architecture of the SAP HANA Data Lake

The Unique Architecture of the SAP Data Lake

Everything you need to know about Extract, Transform and Load (ETL) tools