views:

32

answers:

3

What am I missing in this code below that will cause the error:

Msg 170, level 15, line 113 line 113: Incorrect syntax near 'actual_completion_date'.

update #Loss_mit_step
set
 [STEP924_COMPL_DATE] = Case when step_code ='924' then ls_actual_completion_date else ' ' end,
 [STEP926_COMPL_DATE] = Case when step_code ='926' then ls_actual_completion_date else ' ' end,
 [STEP927_COMPL_DATE] = Case when step_code ='927' then ls_actual_completion_date else ' ' end,
 [STEP928_COMPL_DATE] = Case when step_code ='928' then ls_actual_completion_date else ' ' end,
 [APPROVAL_DATE] = Case when step_code ='Q28' then ls_actual_completion_date else ' ' end
+2  A: 

You appear to have an extra comma in the statement, at the very end.


I suggest you comment out each of the "case" lines, one by one, until you find out what the problem is, or until you only have one line left.

John Saunders
+1, what i was just typing up!
KM
removed the last comma, still get the error???
JMS49
A: 

I found the cause of the error: a space in front of actual_completion_date on the first line.

JMS49
You edited to remove the trailing comma that John Saunders noted. Anyway, I see no space above...
gbn
next time, post the entire query, the tiny fragment you posted was not what you fixed, there is no space in it.
KM
+2  A: 

What you posted is syntactically correct, so you cannot get a syntax error. It actually parses fine. Your error message mentions actual_completion_date but you have no such token in your post. So obviously you posted an error from a different T-SQL.

Remus Rusanu