【发布时间】:2020-03-19 22:20:04
【问题描述】:
我正在尝试将一些数据从 csv 文件加载到 SQL Server 中的表中。我收到一个语法错误,告诉我“''”附近有问题。那是撇号,其间有零宽度无间断空间。
我检查了,我尝试加载的数据中没有这个字符。
这是 Pentaho 显示的错误。
2020/03/19 19:06:23 - SMS Output.0 - ERROR (version 8.3.0.0-371, build 8.3.0.0-371 from 2019-06-11 11.09.08 by buildguy) : Because of an error, this step can't continue:
2020/03/19 19:06:23 - SMS Output.0 - ERROR (version 8.3.0.0-371, build 8.3.0.0-371 from 2019-06-11 11.09.08 by buildguy) : org.pentaho.di.core.exception.KettleException:
2020/03/19 19:06:23 - SMS Output.0 - Error batch inserting rows into table [DailySMS].
2020/03/19 19:06:23 - SMS Output.0 - Errors encountered (first 10):
2020/03/19 19:06:23 - SMS Output.0 - Incorrect syntax near ''.
2020/03/19 19:06:23 - SMS Output.0 - Incorrect syntax near ''.
2020/03/19 19:06:23 - SMS Output.0 - Incorrect syntax near ''.
2020/03/19 19:06:23 - SMS Output.0 - Incorrect syntax near ''.
2020/03/19 19:06:23 - SMS Output.0 - Incorrect syntax near ''.
2020/03/19 19:06:23 - SMS Output.0 - Incorrect syntax near ''.
2020/03/19 19:06:23 - SMS Output.0 - Incorrect syntax near ''.
2020/03/19 19:06:23 - SMS Output.0 - Incorrect syntax near ''.
2020/03/19 19:06:23 - SMS Output.0 - Incorrect syntax near ''.
2020/03/19 19:06:23 - SMS Output.0 - Incorrect syntax near ''.
2020/03/19 19:06:23 - SMS Output.0 -
2020/03/19 19:06:23 - SMS Output.0 -
2020/03/19 19:06:23 - SMS Output.0 - Error updating batch
2020/03/19 19:06:23 - SMS Output.0 - Incorrect syntax near ''.
2020/03/19 19:06:23 - SMS Output.0 -
2020/03/19 19:06:23 - SMS Output.0 -
2020/03/19 19:06:23 - SMS Output.0 - at org.pentaho.di.trans.steps.tableoutput.TableOutput.writeToTable(TableOutput.java:348)
2020/03/19 19:06:23 - SMS Output.0 - at org.pentaho.di.trans.steps.tableoutput.TableOutput.processRow(TableOutput.java:125)
2020/03/19 19:06:23 - SMS Output.0 - at org.pentaho.di.trans.step.RunThread.run(RunThread.java:62)
2020/03/19 19:06:23 - SMS Output.0 - at java.lang.Thread.run(Unknown Source)
2020/03/19 19:06:23 - SMS Output.0 - Caused by: org.pentaho.di.core.exception.KettleDatabaseBatchException:
2020/03/19 19:06:23 - SMS Output.0 - Error updating batch
2020/03/19 19:06:23 - SMS Output.0 - Incorrect syntax near ''.
2020/03/19 19:06:23 - SMS Output.0 -
2020/03/19 19:06:23 - SMS Output.0 - at org.pentaho.di.core.database.Database.createKettleDatabaseBatchException(Database.java:1430)
2020/03/19 19:06:23 - SMS Output.0 - at org.pentaho.di.trans.steps.tableoutput.TableOutput.writeToTable(TableOutput.java:295)
2020/03/19 19:06:23 - SMS Output.0 - ... 3 more
2020/03/19 19:06:23 - SMS Output.0 - Caused by: java.sql.BatchUpdateException: Incorrect syntax near ''.
2020/03/19 19:06:23 - SMS Output.0 - at net.sourceforge.jtds.jdbc.JtdsStatement.executeBatch(JtdsStatement.java:1069)
2020/03/19 19:06:23 - SMS Output.0 - at org.pentaho.di.trans.steps.tableoutput.TableOutput.writeToTable(TableOutput.java:291)
2020/03/19 19:06:23 - SMS Output.0 - ... 3 more
2020/03/19 19:06:23 - CargaSMS - ERROR (version 8.3.0.0-371, build 8.3.0.0-371 from 2019-06-11 11.09.08 by buildguy) : Errors detected!
我尝试更改数据字段类型以查看是否有帮助,但仍然显示此错误。
Pentaho 8.3 版
SQL Server 2008
编辑1
我正在处理的文件被编码为 UTF-8-BOM。我尝试按照用户的建议将它们转换为 UTF-8,但没有奏效。我开始怀疑这些文件与此无关。
我尝试使用 Pentaho 创建一个新表。
CREATE TABLE dbo.DailySMS_test2
(
celular VARCHAR(15)
, msg VARCHAR(149)
, id VARCHAR(15)
, status VARCHAR(100)
, DateSent VARCHAR(100)
)
;
我遇到了同样的错误
Incorrect syntax near ''.
我也尝试将 Pentaho 生成的查询复制到 SSMS 中,并收到此错误:
Msg 102, Level 15, State 1, Line 3
Incorrect syntax near ''.
【问题讨论】:
-
U+FEFF 零宽度不中断?那不是字节反转(U + FFFE)的Unicode字节顺序标记吗?尝试使用 Notepad++ 或 Visual Studio Code 打开您的 .CSV 文件,然后将它们重新保存为适当的格式,但没有字节顺序标记。
-
@AlwaysLearning 我试过了,但没用。我用 Notepadd++ 打开文件并将其保存为 UTF-8(之前是 UTF-8-BOM)并尝试用 Pentaho 加载该文件的内容。同样的错误。
标签: sql-server pentaho pentaho-spoon pentaho-data-integration