A map in my ArcGIS Pro 3.0.3 project has a layer with a Query Feature Class as its source. I can see the SQL that defines the Query Feature Class by looking at its Layer Properties. That SQL is based on tables in an SQL Server Enterprise Geodatabase. I can get at many properties of the layer using the test code below: import arcpy aprx = arcpy.mp.ArcGISProject(r"\\testfolder\testproject.aprx") mapx = aprx.listMaps("Test Map")[0] lyrx = mapx.listLayers("Test Layer")[0] arcpy.AddMessage(f"Layer Name: {lyrx.name}") arcpy.AddMessage(f"Data Source: {lyrx.dataSource}") arcpy.AddMessage(f"Definition Query: {lyrx.definitionQuery}") arcpy.AddMessage(f"Connection Properties: {lyrx.connectionProperties}") # definition_queries = lyrx.listDefinitionQueries arcpy.AddMessage(f"Definition Queries: {lyrx.listDefinitionQueries()}") # Create a Describe object from the feature layer. # desc = arcpy.Describe(lyrx) # Print some properties of the feature layer, and its featureclass. # arcpy.AddMessage("Name String: " + desc.nameString) arcpy.AddMessage("Where Clause: " + desc.whereClause) arcpy.AddMessage("Feature class type: " + desc.featureClass.featureType) None of these are able to access the SQL code that defines the Query Feature Class. Is there a way to bring the SQL code that defines the Query Feature Class into a Python variable for me to work with?