x
login about faq Site discussion (meta-askssc)

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 '10 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 voted first

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 '10 at 10:31 AM

Matt Whitfield gravatar image

Matt Whitfield ♦♦
29.2k 56 63 87

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

Greg Low raised a Connect issue regarding this: http://connect.microsoft.com/SQLServer/feedback/details/303972/cdc-function-error-messages-are-misleading It's closed as won't fix, but if we all vote it up...

(sorry - this should be a comment on the answer, but I don't have the rep.)

more ▼

answered Mar 28 at 04:54 AM

piers7 gravatar image

piers7
10

I've voted you up - which helps you on your way to having the rep required! ;-)

Mar 28 at 09:22 AM ThomasRushton ♦
(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 '12 at 10:27 PM

TheSmilingDBA gravatar image

TheSmilingDBA
81 1 1 2

(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 '10 at 10:32 AM

Jason Crider gravatar image

Jason Crider
453 9 10 12

(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 '12 at 10:27 PM

TheSmilingDBA gravatar image

TheSmilingDBA
81 1 1 2

(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.

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



Facebook logo Follow Ask SSC on Facebook
Find Ask SSC on Google+
linkedin logo Find us on LinkedIn

Topics:

x1601
x12

asked: Jan 15 '10 at 04:41 PM

Seen: 2737 times

Last Updated: Mar 28 at 09:22 AM

Copyright © 2002-2012 Simple Talk Publishing. All Rights Reserved. If you have any queries, please contact the site administrators.
Ask SQL Server Central is a community service provided by Red Gate.