Friday, June 13, 2014

CHANGE DATA CAPTURE(CDC)

-----ENABLE CDC ON CURRENT DATABASE-----

 EXEC SP_CDC_ENABLE_DB

----ENABLE CDC ON CURRENT  TABLE------

 GO
EXEC SP_CDC_ENABLE_TABLE
@SOURCE_SCHEMA=N'DBO',
@SOURCE_NAME=N'MARKS',
@ROLE_NAME=N'PUBLIC'
GO
SELECT * FROM MARKS
SELECT * FROM CDC.DBO_MARKS_CT
INSERT INTO MARKS VALUES(7,12,45,45)
DELETE FROM MARKS WHERE SID=3
UPDATE MARKS SET M1=50 WHERE SID=1

------------------------------------------
------ENABLE CDC ON CURRENT TABLE IN ONLT 1 COLUMN-----

SELECT * FROM QWER

EXEC SP_CDC_ENABLE_TABLE
@SOURCE_SCHEMA=N'DBO',
@SOURCE_NAME=N'QWER',
@ROLE_NAME=N'PUBLIC',
@CAPTURED_COLUMN_LIST=N'NAME'
UPDATE QWER SET ID=1 WHERE NAME='AMMU'
SELECT * FROM CDC.DBO_QWER_CT
------------------------------------------
 ---ENABLE CDC ON CURRENT TABLE IN 2 COLUMNS (IN DIS 1 COLUMN  MUST HAVE [INDEX--PK R UNIQUE]R[NOT])----



SELECT * FROM TTTT
EXEC SP_CDC_ENABLE_TABLE
@SOURCE_SCHEMA=N'DBO',
@SOURCE_NAME=N'TTTT',
@ROLE_NAME=N'PUBLIC',

@CAPTURED_COLUMN_LIST=N'ID,NAME'
SELECT * FROM CDC.DBO_TTTT_CT

No comments:

Post a Comment