为什么我在存储过程的这一部分中出现以下语法错误:
关键字' FROM'。
附近的语法不正确
WITH CTE_Residence_Overtime
AS
(
SELECT *
FROM #Residence
)
UPDATE t1
SET t1.over_time = t1.over_time + CONVERT(TIME, CAST(CTE_Residence_Overtime.overtimeHours AS VARCHAR(2))
FROM r_overtime AS t1
INNER JOIN CTE_Residence_Overtime
ON t1.[trans_date] = CTE_Residence_Overtime.[dayDate];
答案 0 :(得分:5)
我认为你缺少一个支架
WITH CTE_Residence_Overtime
AS
(
SELECT *
FROM #Residence
)
UPDATE t1
SET t1.over_time = t1.over_time + CONVERT(TIME, CAST(CTE_Residence_Overtime.overtimeHours AS VARCHAR(2)))
FROM r_overtime AS t1
INNER JOIN CTE_Residence_Overtime
ON t1.[trans_date] = CTE_Residence_Overtime.[dayDate];
答案 1 :(得分:3)
您错过了set
上的结束语:
SET t1.over_time = t1.over_time +
CONVERT(TIME,
CAST(CTE_Residence_Overtime.overtimeHours AS VARCHAR(2)
)
)
------------------------------^
答案 2 :(得分:2)
一个缺失的括号可以让你的生活变得非常繁忙!
WITH CTE_Residence_Overtime
AS
(
SELECT *
FROM #Residence
)
UPDATE t1
SET t1.over_time = t1.over_time + CONVERT(TIME, CAST(CTE_Residence_Overtime.overtimeHours AS VARCHAR(2)))
FROM r_overtime AS t1
INNER JOIN CTE_Residence_Overtime
ON t1.[trans_date] = CTE_Residence_Overtime.[dayDate];