im_odbc - incorrect syntax and ERROR id column not found or its type is unsupported
Hello,
I hope someone can help me. I need to pick application logs from a few MSSQL database tables. 3 of 4 works perfect -there are no issues getting the data, but one table is causing issues.
Below you can see input I am using. As you can see, there is one column name with the Danish character, however, I am not sure if only this is causing trouble. The error I receive is:
ERROR SQLExecDirect failed, 42000:2:102:[Microsoft][SQL Server Native Client 11.0][SQL Server]Incorrect syntax near 'Ą'.; 42000:3:319:[Microsoft][SQL Server Native Client 11.0][SQL Server]Incorrect syntax near the keyword 'with'. If this statement is a common table expression, an xmlnamespaces clause or a change tracking context clause, the previous statement must be terminated with a s (odbc error code: -1)
However, If I remove this column from SELECT, another error occurs:
ERROR id column not found or its type is unsupported.
I received a similar error than I left some additional spaces in the query, but after that, I used notepad++ to make sure I don't leave any hidden characters.
=========================================================
</Input>
<Input odbc_besked>
Module im_odbc
ConnectionString Driver={SQL Server Native Client 11.0};Server=SERVERNAME\mssql2014,port;Database=database_name;Trusted_Connection=yes;
SQL SELECT BeskedType,
Oprettet,
InternBeskedId,
SvarPåInternBeskedId,
Retning,
BeskedArt,
SoapBeskedId,
BeskedId,
HttpStatusCode,
Fra,
Til,
Failover,
EnvelopeStartTag,
SoapHeaderElement,
IndeholderSoapFault,
Stack
FROM table_name WITH (NOLOCK) WHERE InternBeskedId > ?
</Input>
I suspect that WITH (NOLOCK)
is causing the first issue , can you try to remove this?
Also there needs to be a column named id
in the result set so you probably want to add an alias: SELECT ... InternBeskedId as id ...