-- 2021-11-08 Test script for CDC situation resulting in 2 capture instances with the same start_lsn

CREATE DATABASE testDB;
GO

USE testDB;
GO

CREATE TABLE dbo.SampleTable
(
    ID         INT          NOT NULL IDENTITY(1, 1) PRIMARY KEY CLUSTERED,
    Name       VARCHAR(100) NOT NULL,
    Email      VARCHAR(100) NOT NULL,
    rowversion ROWVERSION
);
GO

-- Add some "existing" data
INSERT dbo.SampleTable (Name, Email) VALUES ('Name 1', 'Email1@sugarcrm.com');
GO

-- enable CDC
EXEC sp_cdc_enable_db;
GO

-- Enable CDC for the table
EXEC sys.sp_cdc_enable_table
    @source_schema = 'dbo',
    @source_name = 'SampleTable',
    @capture_instance = 'testDB_dbo_SampleTable',
    @supports_net_changes = 0,
    @role_name = NULL;
GO

-- See the new CaptureInstance
EXEC sp_cdc_help_change_data_capture;
GO
