【发布时间】:2022-01-23 19:20:25
【问题描述】:
我正在尝试使用 SQL 来区分两个字段,但我的字段数据类型之一是文本,另一个是日期。文本字段也采用 UTC 格式,日期字段采用山区标准时间格式。
- extract_date 是日期字段。
- src_msg_date_time 是文本字段
当我在查询下方运行时,查询工作室中出现“自动化错误”。任何帮助请我做错了什么。!
SELECT
A.extract_date AT TIME ZONE 'Mountain Standard Time' AT TIME ZONE 'UTC' AS EventDate,
B.SmsStandardStatusCode,
B.Description,
A.src_msg_date_time,
A.SubID
FROM
[SmsSendLog] A WITH(NOLOCK)
JOIN
[CustomDataView] B WITH(NOLOCK)
ON A.subid=B.SUBSCRIBERID and a.smsjobid=b.SMSJOBID and a.smsbatchid=b.smsbatchid
where DATEDIFF(Day,A.extract_date,GETDATE()) between 0 and 5
and
DATEDIFF(hour,(Convert(Datetime, A.src_msg_date_time,120) AT TIME ZONE 'Mountain Standard Time' AT TIME ZONE 'UTC'),(A.extract_date AT TIME ZONE 'Mountain Standard Time' AT TIME ZONE 'UTC')) between 0 and 2
【问题讨论】:
-
能否也提供一些示例数据?
-
您在查询活动中尝试过吗?通过使用 Query Studio 而不是真正的 Query Activity,您基本上是在为您的查询引入另一组不同的预处理规则。
-
嗨@AdamSpriggs - 我尝试通过将字段保持为不可为空来使用真实的查询活动,它给了我错误:无法将 NULL 值插入不可为空的列中。
标签: sql tsql automation salesforce-marketing-cloud