Skip to main content
Skip table of contents

Sample post-start hook to add CDC jobs

Sample post-start hook for CDC

This script will add Change Data Capture (CDC) capture and cleanup jobs on provisioned virtual databases.

CODE
$VDB_NAME = $env:VDB_DATABASE_NAME

$VDB_INSTANCE = $env:VDB_INSTANCE_NAME

SQLCMD -b -d $VDB_NAME -r0 -Q "EXEC sys.sp_cdc_add_job @job_type = N'capture';EXEC sys.sp_cdc_add_job @job_type = N'cleanup'" -U <Username> -P <Password> -S ".\$VDB_INSTANCE"

exit $LastExitCode

Sample post-start hook for CDC if provisioning is done from a lower database version to SQL2016 or above

This script will add CDC capture, cleanup jobs, and upgrade CDC metadata on provisioned virtual databases.

CODE
$VDB_NAME = $env:VDB_DATABASE_NAME

$VDB_INSTANCE = $env:VDB_INSTANCE_NAME

SQLCMD -b -d $VDB_NAME -r0 -Q "EXEC sys.sp_cdc_add_job @job_type = N'capture';EXEC sys.sp_cdc_add_job @job_type = N'cleanup';EXEC sys.sp_cdc_vupgrade;" -U <Username> -P <Password> -S ".\$VDB_INSTANCE"

exit $LastExitCode

Place real username and password at respective placeholders while using the scripts.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.