sql-serverchange-data-capture

Function sys.fn_cdc_get_max_lsn() returns null


I'm try use the cdc, and i was following these steps.

  1. EXEC sys.sp_cdc_enable_db -- Enable DB
  2. EXEC sys.sp_cdc_enable_table @source_schema = N'DW', @source_name = N'APIprocess', @role_name = NULL, @supports_net_changes = 0--Enable table
  3. Insert and update in the referred table

  4. DECLARE @Begin_LSN BINARY(10), @End_LSN BINARY(10) SET @Begin_LSN =sys.fn_cdc_get_min_lsn('DW_APIprocess') SET @End_LSN = sys.fn_cdc_get_max_lsn() SELECT @Begin_LSN, @End_LSN, N'all'; SELECT * FROM cdc.fn_cdc_get_all_changes_DW_APIprocess( @Begin_LSN , @End_LSN , 'all') -- Try to get the changes

And when i execute the 4th step throw this error:

An insufficient number of arguments were supplied for the procedure or function cdc.fn_cdc_get_all_changes_

Then i searched an answer and i finded some answers but in not any the problem was produced because that the function sys.fn_cdc_get_max_lsn() return null, and in that is my problem. In summary i need knows why that function return null instead of a binary. Thanks.


Solution

  • The problem was that I didn't have active the service of Sql server Agent, after I activated it, the CDC began to track the operations on the table.