AnsweredAssumed Answered

Add Definition Query to all Layers in MXD that reside in SDE only

Question asked by hello7 on Jan 29, 2013
Latest reply on Jan 29, 2013 by hello7
Hi, I am trying to add a definition query to all layers in an MXD that reside in an SDE database and not those that do not. The below code will add the definition query "RID = 111" to all layers in an MXD. How do I manipulate it to only add to those in my SDE database? I tried the wildcard but the names are all different so I was not able to get only the sde layers. Thanks.

import arcpy from arcpy import env env.workspace = "C:/WORKSPACE" mxd = arcpy.mapping.MapDocument("CURRENT") df = arcpy.mapping.ListDataFrames(mxd)[0] CRID = 333 defquery = """ "RID" = """ + str(CRID) for lyr in arcpy.mapping.ListLayers(mxd):         lyr.definitionQuery = defquery

Outcomes