Skip to content

Instantly share code, notes, and snippets.

@garystafford
Last active February 28, 2023 00:20
Show Gist options
  • Save garystafford/d7fbcaa08d0d9f35f072524c1fcf0473 to your computer and use it in GitHub Desktop.
Save garystafford/d7fbcaa08d0d9f35f072524c1fcf0473 to your computer and use it in GitHub Desktop.
-- enable the database for CDC
EXEC msdb.dbo.rds_cdc_enable_db 'tickit'
USE tickit
GO
SELECT * FROM sys.filegroups;
SELECT * FROM sys.database_files;
-- add new filegroup to database
ALTER DATABASE tickit ADD FILEGROUP CDC_FG1;
-- add new file to filegroup
ALTER DATABASE tickit
ADD FILE
(
NAME = cdc_data1,
FILENAME = 'D:\rdsdbdata\DATA\sqldba_data1.ndf',
SIZE = 500 MB,
FILEGROWTH = 50 MB
) TO FILEGROUP CDC_FG1;
-- enabling cdc for a sql server table
EXEC sys.sp_cdc_enable_table
@source_schema = N'crm',
@source_name = N'user',
@role_name = N'admin',
@filegroup_name = N'CDC_FG1',
@supports_net_changes = 0
GO
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment