Skip to main content

I am using an SQLExecutor to write spatial data into an ArcGIS Enterprise database table.

It took me a while to get it done, and there is still more work to do but currently a smaller chunk of data is for the first time written into the table. What bugs me is the 4 lines of warning that I get for every feature written.

Microsoft SQL Server Spatial Reader: Getting Custom SQL schema failed. Custom SQL query 'INSERT
    INTO
    building (OBJECTID,SHAPE)
VALUES (27, geometry::STGeomFromWKB(here is of course the binary, 25832))' may execute in an unexpected manner. Make sure all columns are named (any ambiguous columns, e.g. GEOM.STBuffer(1), must have an AS clause). If there is an ORDER BY clause, either remove it or add a TOP clause. If this warning is generated in a SQLCreator or SQLExecutor, you can avoid it by picking Data Features in the Features to Read field

 

  1. the message coming from Microsoft SQL Server Spatial Reader seems strange
  2. how can I avoid this in the SQLExecutor? Should I set the ‘Features to Read’ to Data Features?

I think the warning is coming because there is nothing being returned and FME is having a bit of a meltdown because it’s expecting got get features back with some kind of schema. The warning is letting you know that the call didn’t return any values.

I found this which might help https://stackoverflow.com/questions/7917695/sql-server-return-value-after-insert

Essentially here the call needs to return a value - FME can then build a schema out of it and the warning can go away.

Is there a reason that you’re not using the writer for this kind of stuff?


@virtualcitymatt Thanks for the link and I will have a look at it and implement it if that solves the problem.

Unfortunately there is a reason why I am trying to avoid the use of  writer. Actually two.

  1. It needs an ArcGIS Pro installation on the FME Server (Flow) machine to use ArcGIS SDE reader/writers
  2. the speed that the Arc SDE reader/writers offer is not up to par, considering we are querying a database. Reading with the SQLExecutor, altering a bit the schema of the data and writing them out to a dgn… about 500.000 features takes about 5 minutes and is way faster then the ArcGIS SDE reader. Now I hope we can achieve similar results for the writer.

Hi @virtualcitymatt,

adding OUTPUT Inserted.OBJECTID does return the objectid value, but it does not avoid the warnings about Microsoft  SQL Server Spatial Reader, coming from the SQLExecutor.

Now the warning simply got the output line added:

Microsoft SQL Server Spatial Reader: Getting Custom SQL schema failed. Custom SQL query 'INSERT
    INTO
    building (OBJECTID,SHAPE)
    OUTPUT Inserted.OBJECTID
VALUES (27, geometry::STGeomFromWKB(here is of course the binary, 25832))' may execute in an unexpected manner. Make sure all columns are named (any ambiguous columns, e.g. GEOM.STBuffer(1), must have an AS clause). If there is an ORDER BY clause, either remove it or add a TOP clause. If this warning is generated in a SQLCreator or SQLExecutor, you can avoid it by picking Data Features in the Features to Read field

 

 


Hi @virtualcitymatt,

adding OUTPUT Inserted.OBJECTID does return the objectid value, but it does not avoid the warnings about Microsoft  SQL Server Spatial Reader, coming from the SQLExecutor.

Now the warning simply got the output line added:

Microsoft SQL Server Spatial Reader: Getting Custom SQL schema failed. Custom SQL query 'INSERT
    INTO
    building (OBJECTID,SHAPE)
    OUTPUT Inserted.OBJECTID
VALUES (27, geometry::STGeomFromWKB(here is of course the binary, 25832))' may execute in an unexpected manner. Make sure all columns are named (any ambiguous columns, e.g. GEOM.STBuffer(1), must have an AS clause). If there is an ORDER BY clause, either remove it or add a TOP clause. If this warning is generated in a SQLCreator or SQLExecutor, you can avoid it by picking Data Features in the Features to Read field

 

 

Ahh interesting - too bad. I wonder if the issue is because of the format is spatial - So the reader is expecting a geometry

 

What happens if you try and use non-spatial version of the format. In this case the non spatial wont expect any geometry on the output. 

Another similar issue here:

SQLCreator warnings and geometry not read when using order by with SQL Server | Community (safe.com)


I was having the same issue. I tried everything until I did something absolutely non related then the error was gone, I removed “ ; ” (semicolon) from the end of my T-SQL statement: 

This was my code with semicolon:

SELECT i.>name] AS DatabaseName

,(i.
,((i.bsize]/128.0) - CAST(FILEPROPERTY(i.Rname],'SpaceUsed') AS int)/128.0) AS EmptySpaceInMB

FROM sys.database_files as i;

 

This is my new code (without semicolon):

 

SELECT i.dname] AS DatabaseName

,(i./size]/128.0) AS FileSizeInMB

,((i.>size]/128.0) - CAST(FILEPROPERTY(i.Ename],'SpaceUsed') AS int)/128.0) AS EmptySpaceInMB

FROM sys.database_files as i


Reply