<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic ListFields fails on enterprise GDB feature dataset with relationship class in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/listfields-fails-on-enterprise-gdb-feature-dataset/m-p/1652184#M74719</link>
    <description>&lt;P&gt;Howdy!&amp;nbsp; My colleagues and I are having some difficulty trying to run the ListFields function against a feature dataset in an enterprise geodatabase that contains relationship classes.&amp;nbsp; We are simply trying to export a list of all feature classes and their respective fields within every single feature dataset in a particular database.&amp;nbsp; But it errors out on exclusively when ran against a feature dataset that contain relationship classes; if we run this against a feature dataset without any relationship classes, the code runs just fine.&amp;nbsp; Below is the code we have:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
import os

geodatabase_path = r"C:\PathTo\Database Connection.sde"

output_file_path = r"C:\Temp\Output.txt"

with open(output_file_path, "w") as f:
    arcpy.env.workspace = geodatabase_path
    datasets = arcpy.ListDatasets("*BadFeatureDataset*", "FeatureDataset")
    f.write(f"Feature Dataset: {datasets}\n")    
    for ds in datasets:
        for fc_fd in arcpy.ListFeatureClasses(feature_type='Polygon', feature_dataset=ds):
            print (fc_fd)
            f.write(f"Feature Class: {fc_fd}\n")
            fields_fc_fd = arcpy.ListFields(fc_fd)
            for field in fields_fc_fd:
                f.write(f"{field.name}, {field.type}\n")
    f.write("\n")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;Traceback (most recent call last):&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;File "&amp;lt;string&amp;gt;", line 33, in &amp;lt;module&amp;gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\__init__.py", line 1214, in ListFields&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;return gp.listFields(dataset, wild_card, field_type)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py", line 362, in listFields&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;self._gp.ListFields(*gp_fixargs(args, True)))&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;RuntimeError: ERROR 999999: Something unexpected caused the tool to fail. Contact Esri Technical Support (&lt;A href="http://esriurl.com/support" target="_blank" rel="noopener"&gt;http://esriurl.com/support&lt;/A&gt;) to Report a Bug, and refer to the error help for potential solutions or workarounds.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;DBMS table not found [42S02:[Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Invalid object name 'gisdata.OWNER.FeatureClassName'.] [gisdata.OWNER.FeatureClassName][STATE_ID = 108472]&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;Note that this is just sampling of the error; the full error lists all of the 20+ relationship class DBMS tables it cannot find (even though they exist and, from what I understand, the code is not even searching against).&amp;nbsp; Plus, in our effort to troubleshoot, we simplified the code a bit to only run against the problematic feature dataset.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;I'm wondering if it's a glitch we've stumbled upon.&amp;nbsp; For reference we are running this on a machine with ArcGIS Pro 3.2.0 installed and have tested this with the Python Window and Notebook.&lt;/P&gt;</description>
    <pubDate>Mon, 22 Sep 2025 17:39:51 GMT</pubDate>
    <dc:creator>Brownschuh</dc:creator>
    <dc:date>2025-09-22T17:39:51Z</dc:date>
    <item>
      <title>ListFields fails on enterprise GDB feature dataset with relationship class</title>
      <link>https://community.esri.com/t5/python-questions/listfields-fails-on-enterprise-gdb-feature-dataset/m-p/1652184#M74719</link>
      <description>&lt;P&gt;Howdy!&amp;nbsp; My colleagues and I are having some difficulty trying to run the ListFields function against a feature dataset in an enterprise geodatabase that contains relationship classes.&amp;nbsp; We are simply trying to export a list of all feature classes and their respective fields within every single feature dataset in a particular database.&amp;nbsp; But it errors out on exclusively when ran against a feature dataset that contain relationship classes; if we run this against a feature dataset without any relationship classes, the code runs just fine.&amp;nbsp; Below is the code we have:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
import os

geodatabase_path = r"C:\PathTo\Database Connection.sde"

output_file_path = r"C:\Temp\Output.txt"

with open(output_file_path, "w") as f:
    arcpy.env.workspace = geodatabase_path
    datasets = arcpy.ListDatasets("*BadFeatureDataset*", "FeatureDataset")
    f.write(f"Feature Dataset: {datasets}\n")    
    for ds in datasets:
        for fc_fd in arcpy.ListFeatureClasses(feature_type='Polygon', feature_dataset=ds):
            print (fc_fd)
            f.write(f"Feature Class: {fc_fd}\n")
            fields_fc_fd = arcpy.ListFields(fc_fd)
            for field in fields_fc_fd:
                f.write(f"{field.name}, {field.type}\n")
    f.write("\n")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;Traceback (most recent call last):&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;File "&amp;lt;string&amp;gt;", line 33, in &amp;lt;module&amp;gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\__init__.py", line 1214, in ListFields&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;return gp.listFields(dataset, wild_card, field_type)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py", line 362, in listFields&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;self._gp.ListFields(*gp_fixargs(args, True)))&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;RuntimeError: ERROR 999999: Something unexpected caused the tool to fail. Contact Esri Technical Support (&lt;A href="http://esriurl.com/support" target="_blank" rel="noopener"&gt;http://esriurl.com/support&lt;/A&gt;) to Report a Bug, and refer to the error help for potential solutions or workarounds.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;DBMS table not found [42S02:[Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Invalid object name 'gisdata.OWNER.FeatureClassName'.] [gisdata.OWNER.FeatureClassName][STATE_ID = 108472]&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;Note that this is just sampling of the error; the full error lists all of the 20+ relationship class DBMS tables it cannot find (even though they exist and, from what I understand, the code is not even searching against).&amp;nbsp; Plus, in our effort to troubleshoot, we simplified the code a bit to only run against the problematic feature dataset.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;I'm wondering if it's a glitch we've stumbled upon.&amp;nbsp; For reference we are running this on a machine with ArcGIS Pro 3.2.0 installed and have tested this with the Python Window and Notebook.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Sep 2025 17:39:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/listfields-fails-on-enterprise-gdb-feature-dataset/m-p/1652184#M74719</guid>
      <dc:creator>Brownschuh</dc:creator>
      <dc:date>2025-09-22T17:39:51Z</dc:date>
    </item>
    <item>
      <title>Re: ListFields fails on enterprise GDB feature dataset with relationship class</title>
      <link>https://community.esri.com/t5/python-questions/listfields-fails-on-enterprise-gdb-feature-dataset/m-p/1652200#M74720</link>
      <description>&lt;P&gt;Try using arcpy.da.walk, its more robust.&lt;/P&gt;&lt;P&gt;Untested.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
import os

geodatabase_path = r"C:\PathTo\Database Connection.sde"
output_file_path = r"C:\Temp\Output.txt"

with open(output_file_path, "w") as f:
    # Use arcpy.da.Walk to navigate the geodatabase structure
    for dirpath, dirnames, filenames in arcpy.da.Walk(geodatabase_path, datatype="FeatureClass"):
        # Check if we're in a feature dataset
        if geodatabase_path in dirpath and geodatabase_path != dirpath:
            f.write(f"Feature Dataset: {os.path.basename(dirpath)}\n")
        
        for filename in filenames:
            fc_path = os.path.join(dirpath, filename)
            print(filename)
            f.write(f"Feature Class: {filename}\n")
            
            try:
                fields = arcpy.ListFields(fc_path)
                for field in fields:
                    f.write(f"{field.name}, {field.type}\n")
            except Exception as e:
                f.write(f"Error reading fields for {filename}: {str(e)}\n")
                continue
                
        f.write("\n")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Sep 2025 18:59:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/listfields-fails-on-enterprise-gdb-feature-dataset/m-p/1652200#M74720</guid>
      <dc:creator>TonyAlmeida</dc:creator>
      <dc:date>2025-09-22T18:59:50Z</dc:date>
    </item>
    <item>
      <title>Re: ListFields fails on enterprise GDB feature dataset with relationship class</title>
      <link>https://community.esri.com/t5/python-questions/listfields-fails-on-enterprise-gdb-feature-dataset/m-p/1652213#M74721</link>
      <description>&lt;P&gt;Your script is working as expected for me.&lt;/P&gt;&lt;P&gt;I tested on machine with Pro 3.2.1 and one with Pro 3.1.3, both connecting to SQL server sde 10.9.1.2.9 database.&lt;/P&gt;&lt;P&gt;Not all the featureclasses in my feature dataset have relationship classes, but many do and they get reported just the same.&lt;/P&gt;&lt;P&gt;R_&lt;/P&gt;</description>
      <pubDate>Mon, 22 Sep 2025 19:51:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/listfields-fails-on-enterprise-gdb-feature-dataset/m-p/1652213#M74721</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2025-09-22T19:51:44Z</dc:date>
    </item>
    <item>
      <title>Re: ListFields fails on enterprise GDB feature dataset with relationship class</title>
      <link>https://community.esri.com/t5/python-questions/listfields-fails-on-enterprise-gdb-feature-dataset/m-p/1652385#M74722</link>
      <description>&lt;P&gt;Very odd, I tried my original code on our test enterprise environment and got the same results.&amp;nbsp; Both are 10.9.1 enterprise geodatabases.&lt;/P&gt;&lt;P&gt;I also stood up a non enterprise file geodatabase with a feature dataset with one feature class and a relationship class to a standalone table.&amp;nbsp; That did not fail.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Sep 2025 13:17:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/listfields-fails-on-enterprise-gdb-feature-dataset/m-p/1652385#M74722</guid>
      <dc:creator>Brownschuh</dc:creator>
      <dc:date>2025-09-23T13:17:54Z</dc:date>
    </item>
    <item>
      <title>Re: ListFields fails on enterprise GDB feature dataset with relationship class</title>
      <link>https://community.esri.com/t5/python-questions/listfields-fails-on-enterprise-gdb-feature-dataset/m-p/1652404#M74723</link>
      <description>&lt;P&gt;This worked!&amp;nbsp; Just tested it and it produced the results we were seeking.&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":thumbs_up:"&gt;👍&lt;/span&gt;&lt;span class="lia-unicode-emoji" title=":thumbs_up:"&gt;👍&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Sep 2025 13:39:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/listfields-fails-on-enterprise-gdb-feature-dataset/m-p/1652404#M74723</guid>
      <dc:creator>Brownschuh</dc:creator>
      <dc:date>2025-09-23T13:39:19Z</dc:date>
    </item>
    <item>
      <title>Re: ListFields fails on enterprise GDB feature dataset with relationship class</title>
      <link>https://community.esri.com/t5/python-questions/listfields-fails-on-enterprise-gdb-feature-dataset/m-p/1652610#M74726</link>
      <description>&lt;P&gt;Oh and just for reference, I tested the original problematic code on another machine running Pro 2.9.0 against the 10.9.1 enterprise geodatabases and it still produced the same error.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Sep 2025 20:42:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/listfields-fails-on-enterprise-gdb-feature-dataset/m-p/1652610#M74726</guid>
      <dc:creator>Brownschuh</dc:creator>
      <dc:date>2025-09-23T20:42:52Z</dc:date>
    </item>
    <item>
      <title>Re: ListFields fails on enterprise GDB feature dataset with relationship class</title>
      <link>https://community.esri.com/t5/python-questions/listfields-fails-on-enterprise-gdb-feature-dataset/m-p/1652635#M74727</link>
      <description>&lt;P&gt;that is weird, something different in the data I guess.&lt;BR /&gt;This is what I used:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy

geodatabase_path = r"Database Connections\PublicWorks.sde"

output_file_path = r"C:\Temp\Output.txt"

with open(output_file_path, "w") as f:
    arcpy.env.workspace = geodatabase_path
    datasets = arcpy.ListDatasets("*Storm_Features*", "Feature")
    f.write(f"Feature Dataset: {datasets}\n")    
    for ds in datasets:
        for fc_fd in arcpy.ListFeatureClasses(feature_type='Polygon', feature_dataset=ds):
            print (fc_fd)
            f.write(f"Feature Class: {fc_fd}\n")
            fields_fc_fd = arcpy.ListFields(fc_fd)
            for field in fields_fc_fd:
                f.write(f"{field.name}, {field.type}\n")
    f.write("\n")&lt;/LI-CODE&gt;&lt;P&gt;And this is what came out (I removed all but the two sdStructure FC's in the output.txt file, one with and one without relationship class:&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="RhettZufelt_0-1758662329744.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/140841iDB2EB3B16F94A314/image-size/medium?v=v2&amp;amp;px=400" role="button" title="RhettZufelt_0-1758662329744.png" alt="RhettZufelt_0-1758662329744.png" /&gt;&lt;/span&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="RhettZufelt_1-1758662393908.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/140842iADA8B6E81EFEDF94/image-size/medium?v=v2&amp;amp;px=400" role="button" title="RhettZufelt_1-1758662393908.png" alt="RhettZufelt_1-1758662393908.png" /&gt;&lt;/span&gt;&lt;BR /&gt;Thought maybe it was because of&amp;nbsp;"FeatureDataset" in the ListDatasets call, but seems to work the same with that or "Feature".&lt;BR /&gt;R_&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Sep 2025 21:22:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/listfields-fails-on-enterprise-gdb-feature-dataset/m-p/1652635#M74727</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2025-09-23T21:22:38Z</dc:date>
    </item>
  </channel>
</rss>

