https://docs.microsoft.com/en-us/sql/relational-databases/track-changes/administer-and-monitor-change-data-capture-sql-server#Capture
USE msdb;
DECLARE @schedule_uid uniqueidentifier;
DECLARE @collection_set_id int;
DECLARE @cid int;
DECLARE @pp xml = CONVERT(xml,
N'<ns:TSQLQueryCollector xmlns:ns="DataCollectorType">
<Query>
<Value>SELECT * FROM sys.dm_cdc_log_scan_sessions</Value>
<OutputTable>cdc_log_scan_data</OutputTable>
</Query>
</ns:TSQLQueryCollector>');
-- Collect and upload data every 5 minutes
SELECT @schedule_uid = (
SELECT schedule_uid from sysschedules_localserver_view
WHERE name = N'CollectorSchedule_Every_5min')
EXEC dbo.sp_syscollector_create_collection_set
@name = N' CDC Performance Data Collector',
@schedule_uid = @schedule_uid,
@collection_mode = 0,
@days_until_expiration = 30,
@description = N'This collection set collects CDC metadata',
@collection_set_id = @collection_set_id output;
print @collection_set_id ;
-- Create a collection item using statistics from
-- the change data capture dynamic management view.
EXEC dbo.sp_syscollector_create_collection_item
@collection_set_id = @collection_set_id,
@collector_type_uid = N'302E93D1-3424-4BE7-AA8E-84813ECF2419',
@name = ' CDC Performance Data Collector',
@frequency = 5,
@parameters = @pp,
@collection_item_id = @cid output;
print @cid
GO
--sp_syscollector_delete_collection_item @name = N' CDC Performance Data Collector'
--sp_syscollector_delete_collection_set @name = N' CDC Performance Data Collector'
编辑推荐:
- cdc performance turning and monitor03-02
- mssql复制ID03-02
- cdc 延迟再现03-02
- 必要的建表权限03-02
- sql server dba大牛的秘籍03-02
- whoisactive03-02
- Logon failed for login due to trigger execution03-02
- 查看所有外键03-02
下一篇:
相关推荐
-
雷神推出 MIX PRO II 迷你主机:基于 Ultra 200H,玻璃上盖 + ARGB 灯效
2 月 9 日消息,雷神 (THUNDEROBOT) 现已宣布推出基于英
-
制造商 Musnap 推出彩色墨水屏电纸书 Ocean C:支持手写笔、第三方安卓应用
2 月 10 日消息,制造商 Musnap 现已在海外推出一款 Oce
