x

Issue with fn_cdc_get_all_changes

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?

more ▼

asked Jan 15, 2010 at 04:41 PM in Default

Laura Grimes gravatar image

Laura Grimes
22 1 1 1

(comments are locked)
10|1200 characters needed characters left

6 answers: sort oldest

From MSDN:

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.").

more ▼

answered Jan 16, 2010 at 10:31 AM

Matt Whitfield gravatar image

Matt Whitfield ♦♦
29.5k 61 65 87

(comments are locked)
10|1200 characters needed characters left

Clarification: I guess more specifically, I know why I'm getting the 208 return code but how to I get data from the CDC table when I have a date not a specific lsn for that CDC table?

more ▼

answered Jan 18, 2010 at 01:44 PM

Laura Grimes gravatar image

Laura Grimes
22 1 1 1

(comments are locked)
10|1200 characters needed characters left

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.

more ▼

answered May 07, 2010 at 10:32 AM

Jason Crider gravatar image

Jason Crider
453 10 10 12

(comments are locked)
10|1200 characters needed characters left

I changed the begin date to the start of the data in the table and was successful.

Thomas
more ▼

answered Mar 05, 2012 at 10:27 PM

TheSmilingDBA gravatar image

TheSmilingDBA
91 1 1 3

(comments are locked)
10|1200 characters needed characters left

I changed the begin date to be in the range of the data entered into the table and the error went away.

Thomas
more ▼

answered Mar 05, 2012 at 10:27 PM

TheSmilingDBA gravatar image

TheSmilingDBA
91 1 1 3

(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

New code box

There's a new way to format code on the site - the red speech bubble logo will automatically format T-SQL for you. The original code box is still there for XML, etc. More details here.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.

Topics:

x1846
x18

asked: Jan 15, 2010 at 04:41 PM

Seen: 4605 times

Last Updated: Mar 28, 2013 at 09:22 AM