I'm upgrading my SQL Server 2000 database to SQL Server 2008 R2. I want to make use of Change Data Capture feature. Im my existing application I have the similar functionality, but I'm using triggers and historical table with Hst_
prefix with almost similar schema as the original tables.
My question is: is there any way to migrate my data from Hst_
tables to the tables used by CDC feature?
I was thinking of doing that like this:
- I have the table
Cases
. - I'm using my custom historization mechanism , so I also have also three triggers (on insert, update and delete) and a twin table
Hst_Cases
. - Now I'm enabling CDC on table
Cases
- CDC creates function, which returns historical data (
fn_cdc_get_all_changes_dbo_Cases
) and also a system table, which actually holds the data (cdc.dbo_Cases_CT
). - I could insert data from
Hst_Cases
tocdc.dbo_Cases_CT
, but I have the following problems:- I don't know how to get
__$start_lsn
and__$seqval
. - It is difficult to figure out
__$update_mask
(I have to compare each two rows).
- I don't know how to get
Is there the only way to do that? I want to avoid the situation then I join "new" historical data with the "old" historical data from Hst_
tables.
Thanks!