Skip to main content
Solved

SQLExecutor with Custom SQL schema failed warnings by Microsoft SQL Server Spatial Reader

  • February 22, 2024
  • 5 replies
  • 279 views

tb09114
Supporter
Forum|alt.badge.img+22

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?

Best answer by virtualcitymatt

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?

View original
Did this help you find an answer to your question?

5 replies

virtualcitymatt
Celebrity
Forum|alt.badge.img+34
  • Celebrity
  • Best Answer
  • February 23, 2024

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?


tb09114
Supporter
Forum|alt.badge.img+22
  • Author
  • Supporter
  • February 23, 2024

@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.

tb09114
Supporter
Forum|alt.badge.img+22
  • Author
  • Supporter
  • February 26, 2024

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

 

 


virtualcitymatt
Celebrity
Forum|alt.badge.img+34
tb09114 wrote:

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)


australgis
Contributor
Forum|alt.badge.img+3
  • Contributor
  • July 10, 2024

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.[size]/128.0) AS FileSizeInMB

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

FROM sys.database_files as i;

 

This is my new code (without semicolon):

 

SELECT i.[name] AS DatabaseName

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

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

FROM sys.database_files as i


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings