CDC (Change Data Capture) is not capturing data on SQL 2014

Kumari, Meenakshy 1 Reputation point
2022-09-13T04:25:06.987+00:00

Hi ,

I need some help on CDC. I've enabled CDC on database on few tables. Previously it was running fine. After deleting the capture job and recreating , it stops working.
I couldn't find any errors as well.looks all blank.

I tried below steps as well:

-Stop the capture job;
-run EXEC sp_repldone @xactid = NULL, @xact_segno = NULL, @numtrans = 0, @TIME = 0, @EGCC = 1; EXEC sp_replflush;
-Check the sys.dm_cdc_errors table for new rows but no rows ..

Could you help me on this?

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,629 questions
{count} votes

6 answers

Sort by: Most helpful
  1. Olaf Helper 43,901 Reputation points
    2022-09-13T05:10:31.673+00:00

    -run EXEC sp_repl done @xactid = NULL

    Guess why the SP name contains "repl": Because it's for replication, not for CDC.
    Setup CDC with SSMS GUI from scretch to get it working again.

    0 comments No comments

  2. PandaPan-MSFT 1,911 Reputation points
    2022-09-13T05:32:13.223+00:00

    Hi @Kumari, Meenakshy ,
    You can use the following order to see if you have set the database successfully:
    SELECT name,is_cdc_enabled FROM sys.databases WHERE is_cdc_enabled = 1;
    You can use the following order to see if you have set the table successfully:
    SELECT name,is_tracked_by_cdc FROM sys.tables WHERE is_tracked_by_cdc = 1;

    By the way you may set the CDC by the following order:
    USE MyDB
    GO
    EXECUTE sys.sp_cdc_enable_db;
    GO
    240363-image.png
    Best regards
    Jong


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment"

    0 comments No comments

  3. Kumari, Meenakshy 1 Reputation point
    2022-09-13T06:19:54.857+00:00

    Thanks for the reply.

    I've recreated CDC jobs. I can see two jobs are running cdc.apo16t_capture and cdc.apo16t_cleanup jobs but still can't see any data capture. I query one of CT table, select * from cdc.po_requisitioner_*****_CT table and can't see any data capture.

    CDC has been enabled for following tables.

    select * from cdc.change_tables;
    240366-image.png

    Also, checked SELECT name,is_tracked_by_cdc FROM sys.tables WHERE is_tracked_by_cdc = 1;

    240403-image.png
    Is something I'm missing here?

    Thx.


  4. Kumari, Meenakshy 1 Reputation point
    2022-09-13T08:12:16.95+00:00

    Hi Pan,

    Thanks for the prompt reply.

    I've successfully ran the query ALTER AUTHORIZATION ON DATABASE::[MyDB] TO [sa].. Also SQL Agent job is already running.

    I can see the jobs history ,looks all good to me. Also, checked for any errors using query select * from sys.dm_cdc_errors; but all blank with no rows.

    240473-image.png
    240445-image.png

    0 comments No comments

  5. PandaPan-MSFT 1,911 Reputation points
    2022-09-13T08:38:29.28+00:00

    Hi @Kumari, Meenakshy ,
    WOW...then I may give you some notice things that may need to pay attention:

    · SQL Server version must be 2008 or above;

    · Memory-optimized tables (a feature of SQL Server 2014 or later) cannot be used at the same time. Otherwise, the following error occurs:

    · @@ SERVERNAME and serverproperty ( 'servername') must be consistent (the properties of the local server name and the server instance must be consistent). The follow script adjusts that two to be consistent. If the latter two are still inconsistent, the SQL Server service needs to be restarted.

    if serverproperty('servername') <> @@servername
    begin
    declare @Testta sysname
    set @Testta = @@servername
    exec sp_dropserver@Testta =@Testta
    set @Testta = cast(serverproperty('servername') as sysname)
    exec sp_addserver@Testta = @Testta , @rayn = 'LOCAL'
    PRINT 'ok'
    end

    select @@SERVERNAME,serverproperty('servername')

    · The SQL Sever Agent service must be turned on. The CDC function must be implemented by a job.

    · Cannot use TRUNCATE TABLE for tables with CDC enabled. You can disable and truncate before enabling CDC.

    · If the structure of the table changes, a forced conversion will occur in the capture instance table: a new addition cannot be captured, a deleted column remains NULL, and a modified column type. To be on the safe side, disable the capture instance and then enable it.

    · When querying CDC-related tables, it is recommended to add With (NOLOCK), otherwise it is easy to cause blocking or deadlock.

    · A table can have at most two capture instances.
    (I hope this can give you some help)

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.