我正在尝试在复制数据活动中创建动态查询,以基于时间戳从表中提取数据。查找也将获得正确的值
我已经尝试过
从[dbo] .t_tablename中选择*,其中last_changed_date>@ {formatDateTime(activity('Lookup_Get上次更改日期').output.firstRow.lastRecordTimeStamp,'yyyy-MM-ddTHH:mm:ssZ')}
从[dbo] .t_tablename中选择*,其中last_changed_date>@ {activity('Lookup_Get上次更改日期”)。output.firstRow.lastRecordTimeStamp}
从[dbo] .t_tablename中选择*,其中last_changed_date>@activity('Lookup_Get上次更改日期”)。output.firstRow.lastRecordTimeStamp
和其他选项,但它始终会给出错误2200,这是语法错误。
有人可以建议采用什么方法吗?
如果我尝试这个(有效)从[dbo] .t_tablename中选择*,其中last_changed_date>'2019-11-27 16:17:00.000'
语法错误是来自SQL还是来自ADF?
假设它是SQL,在动态构建语句时,您仍需要在where子句值周围加上'(引号):
select * from [dbo].t_tablename where last_changed_date > **'**@{formatDateTime(activity('Lookup_Get Last changed date').output.firstRow.lastRecordTimeStamp,'yyyy-MM-ddTHH:mm:ssZ')}**'**
如果是ADF,请尝试在concat表达式中构建值:
@concat('select * from [dbo].t_tablename where last_changed_date > ''', activity('Lookup_Get Last changed date').output.firstRow.lastRecordTimeStamp, '''')
无论哪种情况,都需要在值两端加上引号。
从[dbo] .t_tablename中选择*,其中last_changed_date>'@ {activity('Lookup_Get上次更改日期').output.firstRow.lastRecordTimeStamp}'
上面的代码现在正在工作...因为它是一个日期时间,所以我们必须在''之间加入活动]