Msg 102, Level 15, State 1, Line 1 Incorrect syntax near ''

I am trying to execute a query from temp table and I keep getting this message:

Msg 102, Level 15, State 1, Line 1 Incorrect syntax near ' '.

Can someone tell me what the problem is? Is it related to the conversion?

Request

select compid,2, convert(datetime, '01/01/' + CONVERT(char(4),cal_yr) ,101) ,0,  Update_dt, th1, th2, th3_pc , Update_id, Update_dt,1
from  #tmp_CTF** 
+5
source share
1 answer

For the OP command:

select compid,2, convert(datetime, '01/01/' + CONVERT(char(4),cal_yr) ,101) ,0,  Update_dt, th1, th2, th3_pc , Update_id, Update_dt,1
from  #tmp_CTF** 

I get this error:

Msg 102, Level 15, State 1, Line 2
Incorrect syntax near '*'.

when debugging something like this, split the long line so that you get the best line number:

select compid
,2
, convert(datetime
, '01/01/' 
+ CONVERT(char(4)
,cal_yr) 
,101) 
,0
,  Update_dt
, th1
, th2
, th3_pc 
, Update_id
, Update_dt
,1
from  #tmp_CTF** 

this now leads to:

Msg 102, Level 15, State 1, Line 16
Incorrect syntax near '*'.

which probably only from the OP does not put the whole command in the question or uses [] brackets to indicate the table name:

from [#tmp_CTF**]

if it is a table name.

+2
source

All Articles