How to Implement Change data capture on SQL Server | CloudFronts | Microsoft Gold Partner

preview_player
Показать описание
Hello Viewers, in this video we will see what is change data capture in SQL server, how to implement it on actual server and what are its prerequisites.

--SQL Queries to implement CDC

--MAKE YOUR USER OWNER OF DATABASE

EXEC sp_changedbowner 'sa'

--ENABLE CHANGE DATA TRACKING

--CHECK WEATHER CDC IS ENABLED OR NOT

-- Enable CDC on a specific table

@source_schema = 'dbo',

@source_name = 'Accounts',

@role_name = NULL,

@supports_net_changes = 1

-- Check that CDC is enabled in the table

@source_schema = 'dbo',

@source_name = 'Accounts';

GO

--SHOW ACCOUNTS TABLE

SELECT * FROM Accounts

-- CHANGE TRACKING TABLE

SELECT * FROM [CDC].[cdc].[dbo_Accounts_CT]

--INSERT VALUES

--DELETE ROW

DELETE FROM Accounts where ID = 7

--Operation ID's

--1. Delete

--2. Insert

--3. Updated row before the change

--4. Updated row after the change

Edited

Рекомендации по теме
Комментарии
Автор

Hi, i am not able to see the cdc tables like you are able to see SELECT * FROM [CDC].[cdc].[dbo_Accounts_CT], could you please help

anikethdeshpande
Автор

Is there a way sir to know who insert or delete the data?

smf
welcome to shbcf.ru