Skip to main content
Solved

SQL Count function


arenscott
Contributor
Forum|alt.badge.img+5

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;

Best answer by hkingsbury

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

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

9 replies

nielsgerrits
VIP
Forum|alt.badge.img+54

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

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


arenscott
Contributor
Forum|alt.badge.img+5
  • Author
  • Contributor
  • April 22, 2025

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:

 



 


nielsgerrits
VIP
Forum|alt.badge.img+54

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.


arenscott
Contributor
Forum|alt.badge.img+5
  • Author
  • Contributor
  • April 22, 2025

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!


hkingsbury
Celebrity
Forum|alt.badge.img+53
  • Celebrity
  • Best Answer
  • April 22, 2025

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


arenscott
Contributor
Forum|alt.badge.img+5
  • Author
  • Contributor
  • April 22, 2025

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


david_r
Celebrity
  • April 23, 2025

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


arenscott
Contributor
Forum|alt.badge.img+5
  • Author
  • Contributor
  • May 1, 2025

Hi all, 

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


ebygomm
Influencer
Forum|alt.badge.img+32
  • Influencer
  • May 2, 2025

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


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