我正在尝试从临时表中进行查询,但不断收到此消息:
Msg 102, Level 15, State 1, Line 1 Incorrect syntax near ' '.
有人能告诉我问题是什么吗?是因为转换吗?
查询是
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**
最佳答案
对于 OP 的命令:
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**
我收到此错误:
Msg 102, Level 15, State 1, Line 2
Incorrect syntax near '*'.
在调试这样的东西时,将长线分开,这样你就会得到一个更好的行号:
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**
这现在导致:
Msg 102, Level 15, State 1, Line 16
Incorrect syntax near '*'.
这可能只是来自 OP 没有将整个命令放在问题中,或者使用 [] 大括号来表示表名:
from [#tmp_CTF**]
如果那是表名。
关于sql - 消息 102,级别 15,状态 1,第 1 行 ' ' 附近的语法不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2744280/