on 07-26-2022 08:31 AM - edited on 07-26-2022 08:31 AM by ntobon
A column with spatial data and spaces in the column name throws a "Incorrect syntax" error when reading from or writing to SQL Server.
Error when using ODBC:
Input Data (1) Error opening "select "NT_COStoreFileNorth".[new column], "NT_COStoreFileNorth".[polygon column] FROM (SELECT "new column","polygon column".STAsBinary() AS polygon column FROM NT_COStoreFileNorth) "NT_COStoreFileNorth"": No Columns Returned.
Error when using OleDB (with SQL Server Native Client driver):
When using OLEDB (with driver SQL Server Native Client) you get error:
Input Data (3) Error: Microsoft SQL Server Native Client 11.0: Incorrect syntax near the keyword 'column'.\42000 = 156¶ in Query: select NT_COStoreFileNorth.[new column],¶ NT_COStoreFileNorth.[polygon column] ¶from NT_COStoreFileNorth
This error is caused by the spatial data and the inclusion of spaces in the column name. Other data types do not have the same issue with spaces in the column name.
Probably more relevant is that there is a space in an un-quoted field name and part of that name is a reserved word.