I am getting this error "An insufficient number of arguments were supplied for the procedure or function cdc.fn_cdc_get_all_changes_" while trying to execute the following sql query.
use SpatialDB
go
declare @begin_time datetime, @end_time datetime, @from_lsn binary(10), @to_lsn binary(10);
set @begin_time=GETDATE()-1;
set @end_time=GETDATE();
set @from_lsn=sys.fn_cdc_map_time_to_lsn('smallest greater than or equal', @begin_time);
set @to_lsn=sys.fn_cdc_map_time_to_lsn('largest greater than or eqaul', @end_time);
select * from cdc.fn_cdc_get_net_changes_dbo_Points(@from_lsn, @to_lsn, N'all');
go
More Late, but for future seekers . . .
I received this message and the reason is because I had my Start LSN and Ending LSN numbers switched. So, I switched them back and it worked fine.
I ended up with code like:
SELECT DISTINCT sh.siteid1 AS 'Site Number' ,CASE cdc.__$operation WHEN 1 THEN 'D' WHEN 2 THEN 'I' WHEN 4 THEN 'U' END AS CDC_OPERATION FROM site_header sh(NOLOCK) INNER JOIN cdc.fn_cdc_get_net_changes_dbo_svt_svsiteheader(0x00004B04000019300002, 0x00004B0500003A220001, N'All') cdc ON cdc.site_id = sh.site_id LEFT JOIN site_location sl ON sh.id_site = sl.id_site AND sh.primary_id = sl.id_rec
I had the same issue, and Gerald was spot on - if I use LSNs within the range of CDC captured data, no issue.
I'm now capping my LSN values with
sys.fn_cdc_get_min_lsn('my_captureinstance')
andsys.fn_cdc_get_max_lsn()
, e.g:Late, but for future seekers . . .
The error message is somewhat misleading. The parameters that you pass in to the function need to be "valid" or you will get this frustrating error message.
Here is a quote from TechNet for SQL Server 2008 article Using Change Data. I recommend that you read this article.
When I first began using these functions in SQL Server 2012, I was passing in wild parameters that were far outside the range of dates that had been captured by CDC. When I cleaned them up--that is, started using date ranges that were valid--good results followed.
That mecdc.fn_cdc_get_net_changes_dbo_Points requires more arguments. Find the definition of this function to see what it's expecting so you can give it the right number of arguments. This is one of your functions, so none of us know what the arguments should be.