Skip to main content
Question

How to query first row of attribute in all tables of an SDE database

  • September 19, 2023
  • 2 replies
  • 104 views

scarecrow
Contributor
Forum|alt.badge.img+4

Hello,

I have an sde database containing hundreds of feature classes, in which each feature class has an attribute containing a document reference.

I would like to be able to read the first row of attributes from each feature class so that I can check the document reference.

My current workflow uses the SQLExecutor to extract all of the feature class names. Then the names are passed to a FeatureReader to read in each feature class, with the 'Max features to read' set to '1' to save reading more attributes than required.

image.pngHowever, this is still taking a long time to process all the feature classes. Is it possible to do all of this in SQL?

2 replies

nielsgerrits
VIP
Forum|alt.badge.img+54

Assuming the FeatureReader is the bottleneck I would use two SQLExecutors and only request the column you need.

 

First SQLExecutor to get the TableName of all tables.

select table_name as TableName from dbo.[SDE_table_registry]

Then a second SQLExecutor to get the ColumnName from the first row of each table

select top 1 OBJECTID from @Value(TableName)

If I run this on my test db, which is slow, it performs quite well.


scarecrow
Contributor
Forum|alt.badge.img+4
  • Author
  • Contributor
  • September 19, 2023

Thanks @nielsgerrits​ that's worked perfectly.

Just for anyone that has a similar problem.

I used a second SQLExecutor to run nielgerrits SQL query, using the 'name' attribute from the first SQLExecutor in my workbench.

Probably not the most elegant or efficient solutions but gets the job done.

image


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