Skip to main content

Hi all, 

I’d like to use FME to execute some count SQL functions on SQL server (SDE). I’m having trouble with the syntax of the SQL in FME and I’m not receiving any output from the SQL Executor.

 


SQL I’m running:

SELECT COUNT(*)
from "SDE".SAMPLE;

Try in a single line, without semicolon. Use an alias, to expose.

SELECT COUNT(*) as CountRecords from SDE.[sample]


Hi Niels
Thanks for your help. I’m still not getting anything outputted via the SQLExecutor Result port.

 



Here is the log file for the SQL Executor:

 



 


In the SQLExector, open the SQL Editor. (Arrow next to SQL Statement field.) Then in the upper left, click on Database Tables to unfold it. Find your table and double click it to add it to the editor. Just to be sure it written as it should.


Thanks Niels. It turns out that the Database table is correct

I’m able to run a ‘Select * from’ statement successfully, so perhaps something is wrong with how I’m understanding/using the ‘Select count’ function. I may have to reach out to safe support, thanks!


I don’t think you can use a COUNT against SDE like this (using the SDE connection).

You’ll need to use the underlying database connection and run the select against the view or basetable that the SDE FeatureClass is linked to


Thanks hkingbury. I’ll try using a direct connection to SQL Server non spatial


Also, make sure your “sample” table is really located inside the SDE schema (which usually wouldn’t / shouldn’t be the case).


Hi all, 

Thanks for your help. I was able to get this working by querying SQL S non spatial directly


Just be aware that if you’re going direct to the database and have some types of archiving turned on the number you will see from a count statement on the database won’t represent the number of features you’ll return if using an ArcSDE reader


Just be aware that if you’re going direct to the database and have some types of archiving turned on the number you will see from a count statement on the database won’t represent the number of features you’ll return if using an ArcSDE reader

Or use the associated view which combines the base and adds/deletes to show what the dataset is