0

Why I get the following syntax error in this section of stored procedure :

Incorrect syntax near the keyword '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];
2
  • 3
    Looks like you are missing a closing parentheses on that CONVERT() Commented May 20, 2015 at 15:11
  • 2
    Correct your parentheses!!! Commented May 20, 2015 at 15:12

3 Answers 3

5

I think you are missing one bracket

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];
Sign up to request clarification or add additional context in comments.

Comments

3

You are missing a closing paren on the set:

    SET t1.over_time = t1.over_time +
                       CONVERT(TIME,
                               CAST(CTE_Residence_Overtime.overtimeHours AS VARCHAR(2)
                                   )  
                              )
------------------------------^

Comments

2

One missing parenthesis can make your life quite hectic!

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];

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.