SQLServer 2008 Instance My client enabled Change Data Capture in lieu of keeping a history of changes in the baseline table. My challenge is that I need to determine if anything changed since the last time I executed.
I have the following logic:
declare @begin_lsn binary(10), @end_lsn binary(10), @prev_run_dt datetime select @prev_run_dt = getdate() -1 --- example only--getting start date of last successful run select @begin_lsn = sys.fn.cdc_map_time_to_lsn('smallest greater than', @prev_run_dt) select @end_lsn = sys.fn_cdc_get_max_lsn() select * from cdc.fn_cdc_get_all_changes_<change_capture>(@begin_lsn,@end_lsn, N'all')
If there are no changes that have the specific lsn values in my table, the
fn_cdc_get_all_changes FAILS..badly..error code 208. According to documentation, you should not query CDC tables directly but use the functions.
Any suggestions on how to get around this?
Answer by Matt Whitfield ·
If the specified LSN range does not fall within the change tracking timeline for the capture instance, the function returns error 208 ("An insufficient number of arguments were supplied for the procedure or function cdc.fn_cdc_get_all_changes.").
Answer by Jason Crider ·
I started with the following link: http://technet.microsoft.com/en-us/library/cc645858.aspx
See if that Validating LSN Boundaries section at the top helps you at all.
Answer by piers7 ·