sql - 消息 102,级别 15,状态 1,第 1 行 ' ' 附近的语法不正确

标签 sql sql-server-2008

我正在尝试从临时表中进行查询,但不断收到此消息:

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/

相关文章:

sql-server-2008 - SSRS - 将报表部署到本地报表服务器时出现 Excel 数据源错误

mysql - MySQL 中的 CASE 性能?

sql - OLE DB 或 ODBC 错误 : Login failed for user 'NT AUTHORITY\NETWORK SERVICE

sql - 从多对多关系中选择完全外连接

sql-server-2008 - 确定数据库类型

excel - 从 GridView 导出到 Excel 无法正确显示波斯语

sql-server - 当 "include"列不同时为同一列创建索引的正确方法

java - 计算两个 Java Timestamp 对象之间耗时

sql - 使用单元格作为参数在 Excel 中使用 SQL 创建参数化查询

sql - 编写多个条件时的 Case 的更好方法