0

I'm trying to load some data from a csv file into a table in SQL Server. I'm getting a syntax error that tells me that there is something wrong near "''". That's apostrophes with a Zero Width No Break space in between.

I checked and the data I'm trying to load does not have this character in it.

This is the error that Pentaho shows.

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!

I tried changing the data field types to see if it helps, but this erros still shows.

Pentaho version 8.3

SQL Server 2008

EDIT1

The files I'm working with are encoded as UTF-8-BOM. I tried converting them to UTF-8 as a user advised but it didn't work. I'm starting to suspect that the files don't have anything to do with this.

I tried creating a new table using Pentaho.

CREATE TABLE dbo.DailySMS_test2
(
  celular VARCHAR(15)
, msg VARCHAR(149)
, id VARCHAR(15)
, status VARCHAR(100)
, DateSent VARCHAR(100)
)
;

And I'm getting the same error

Incorrect syntax near ''.

I also tried copying the query generated by Pentaho into SSMS and got this error:

Msg 102, Level 15, State 1, Line 3
Incorrect syntax near ''.
2
  • 1
    U+FEFF Zero Width No Break? Isn't that also the Unicode byte order mark with the bytes reversed (U+FFFE)? Try opening your .CSV files with Notepad++ or Visual Studio Code and resaving them to the appropriate format but without the byte order mark. Mar 19, 2020 at 22:50
  • @AlwaysLearning I tried this out, but it didn't work. I opened the file with Notepadd++ and saved it as UTF-8 (it was UTF-8-BOM before) and tried loading the content of this file with Pentaho. Same error.
    – Ahmad Ali
    Mar 23, 2020 at 18:17

1 Answer 1

0

I was able to solve this problem by renaming the first column, thus removing the Zero Width No Break space.

The encoding of the files I was trying to read using Pentaho is UTF-8-BOM, but Pentaho does not have an option to read UTF-8-BOM, only UTF-8. So it simply added the Zero Width No Break space to the begining of the file, which was the name of the first column.

So, by renaming the first column, or simply deleting one character before the first letter, this problem was solved.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.