I had a very similar issue, this turned out to be 2 problems
The first a typo in the first parameter to the function fn_cdc_map_time_to_lsn
, which returned a NULL value which is then passed to the table cdc function resulting the insufficient number of arguments were supplied for the procedure or function cdc.fn_cdc_get_all_changes_
message
The typo was 'largest less than or eqaul'
and should've been 'largest less than or equal'
This resulted in a NULL value being returned when passing a datetime as a string as the second parameter.
BUT confusingly would work when passing in the function GETDATE() but not the string value returned from GETDATE()
The second I believe is due to the datetime being used for the second parameter being a value before CDC was enabled. This occurred due to disabling and enabling CDC more than once
Checked using the function fn_cdc_map_lsn_to_time
to convert the the @from_lsn
value
e.g. the below returned 0x000024FA000010580039
SET @begin_time = '2023-12-08 17:00:00';
SET @from_lsn = sys.fn_cdc_map_time_to_lsn('smallest greater than or equal', @begin_time);
and using the map lsn to time function
SELECT sys.fn_cdc_map_lsn_to_time (0x000024FA000010580039)
returned '2023-12-08 17:04:34.950'
so when using a datetime before the above time with 'largest less than or equal'
resulted in a NULL value
e.g. below resulted in NULL return
SET @end_time = '2023-12-08 17:00:00.000';
SELECT sys.fn_cdc_map_time_to_lsn('largest less than or equal', @end_time);