在 Azure ADF 中使用动态源增量复制 cdc 记录
Incremental copy cdc records with dynamic source in Azure ADF
我在 Azure ADF 中创建了一个管道,用于从源数据库中的 54 table 复制更改的行。我遵循了 Azure 的指南。并修改它以支持动态 tables.
我正在使用查找来获取所有活动的 CDC table,然后对于每个 activity 在每个 CDC table 上执行副本,并且效果很好。但是,当我尝试在 Azure 指南中添加 Trigger_Start_Time 示例代码时,出现此错误:
数据库操作失败,出现以下错误:
'Incorrect syntax near '{'.'
Incorrect syntax near '{'.
, SqlErrorNumber=102,Class=15,State=1.
这是我要执行的代码示例:
@concat('DECLARE @begin_time datetime, @end_time datetime, @from_lsn binary(10), @to_lsn binary(10) ;
SET @begin_time = ''',pipeline().parameters.TriggerStartTime,''';
SET @end_time = ''',pipeline().parameters.TriggerEndTime,''';
SET @from_lsn = sys.fn_cdc_map_time_to_lsn(''smallest greater than or equal'', @begin_time);
SET @to_lsn = sys.fn_cdc_map_time_to_lsn(''largest less than or equal'', @end_time);
SELECT count(1) changecount FROM cdc.fn_cdc_get_net_changes_dbo_@{item().Table_Name}(@from_lsn, @to_lsn, ''all'')')
我使用@{item().Table_Name} 来设置table 名称。如果我将 table 名称硬编码为“Customer”
,效果会很好
当我在查询中使用 source 参数时,我错过了什么?
当在 concat() 函数中包含当前项时,将其用作 item().Table_Name
.
@concat('DECLARE @begin_time datetime, @end_time datetime, @from_lsn binary(10), @to_lsn binary(10) ;
SET @begin_time = ''',pipeline().parameters.TriggerStartTime,''';
SET @end_time = ''',pipeline().parameters.TriggerEndTime,''';
SET @from_lsn = sys.fn_cdc_map_time_to_lsn(''smallest greater than or equal'', @begin_time);
SET @to_lsn = sys.fn_cdc_map_time_to_lsn(''largest less than or equal'', @end_time);
SELECT count(1) changecount FROM cdc.fn_cdc_get_net_changes_dbo_',item().Table_Name,'(@from_lsn, @to_lsn, ''all'')')
管道中的查询如下所示,
我在 Azure ADF 中创建了一个管道,用于从源数据库中的 54 table 复制更改的行。我遵循了 Azure 的指南。并修改它以支持动态 tables.
我正在使用查找来获取所有活动的 CDC table,然后对于每个 activity 在每个 CDC table 上执行副本,并且效果很好。但是,当我尝试在 Azure 指南中添加 Trigger_Start_Time 示例代码时,出现此错误:
数据库操作失败,出现以下错误:
'Incorrect syntax near '{'.'
Incorrect syntax near '{'.
, SqlErrorNumber=102,Class=15,State=1.
这是我要执行的代码示例:
@concat('DECLARE @begin_time datetime, @end_time datetime, @from_lsn binary(10), @to_lsn binary(10) ;
SET @begin_time = ''',pipeline().parameters.TriggerStartTime,''';
SET @end_time = ''',pipeline().parameters.TriggerEndTime,''';
SET @from_lsn = sys.fn_cdc_map_time_to_lsn(''smallest greater than or equal'', @begin_time);
SET @to_lsn = sys.fn_cdc_map_time_to_lsn(''largest less than or equal'', @end_time);
SELECT count(1) changecount FROM cdc.fn_cdc_get_net_changes_dbo_@{item().Table_Name}(@from_lsn, @to_lsn, ''all'')')
我使用@{item().Table_Name} 来设置table 名称。如果我将 table 名称硬编码为“Customer”
,效果会很好当我在查询中使用 source 参数时,我错过了什么?
当在 concat() 函数中包含当前项时,将其用作 item().Table_Name
.
@concat('DECLARE @begin_time datetime, @end_time datetime, @from_lsn binary(10), @to_lsn binary(10) ;
SET @begin_time = ''',pipeline().parameters.TriggerStartTime,''';
SET @end_time = ''',pipeline().parameters.TriggerEndTime,''';
SET @from_lsn = sys.fn_cdc_map_time_to_lsn(''smallest greater than or equal'', @begin_time);
SET @to_lsn = sys.fn_cdc_map_time_to_lsn(''largest less than or equal'', @end_time);
SELECT count(1) changecount FROM cdc.fn_cdc_get_net_changes_dbo_',item().Table_Name,'(@from_lsn, @to_lsn, ''all'')')
管道中的查询如下所示,