我有这个查询,我想得到这两个查询的结果。请注意,这machine_output
是我创建的视图:
SELECT DISTINCT tblcertified.employeenumber,
tblcertified.machinenumber
FROM tblcertified
INNER JOIN machine_output
ON tblcertified.machinenumber = machine_output.machinenumber
UNION
SELECT CONVERT (DATE, tblperiod.fromdate) AS fDate,
tblscheduled.employeenumber
FROM tblperiod
INNER JOIN tblscheduled
ON tblperiod.number = tblscheduled.number
WHERE tblperiod.fromdate BETWEEN Dateadd(m, -3, Getdate()) AND Getdate()
运行上述内容时,出现以下错误:
消息 241,级别 16,状态 1,第 1 行从字符串转换日期和/或时间时转换失败。
当我删除convert
语句时,我也会收到此错误。