<?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 Re: Add Definition Query to all Layers in MXD that reside in SDE only in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/add-definition-query-to-all-layers-in-mxd-that/m-p/595865#M46638</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thats it! Thanks&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 29 Jan 2013 15:09:38 GMT</pubDate>
    <dc:creator>jamesborris</dc:creator>
    <dc:date>2013-01-29T15:09:38Z</dc:date>
    <item>
      <title>Add Definition Query to all Layers in MXD that reside in SDE only</title>
      <link>https://community.esri.com/t5/python-questions/add-definition-query-to-all-layers-in-mxd-that/m-p/595863#M46636</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;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. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;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): &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lyr.definitionQuery = defquery&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Jan 2013 12:57:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/add-definition-query-to-all-layers-in-mxd-that/m-p/595863#M46636</guid>
      <dc:creator>jamesborris</dc:creator>
      <dc:date>2013-01-29T12:57:03Z</dc:date>
    </item>
    <item>
      <title>Re: Add Definition Query to all Layers in MXD that reside in SDE only</title>
      <link>https://community.esri.com/t5/python-questions/add-definition-query-to-all-layers-in-mxd-that/m-p/595864#M46637</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi James,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You can check if the layer resides in an SDE geodatabase by using the Layer's 'dataSource' property.&amp;nbsp; Ex:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;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): &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ".sde" in lyr.dataSource: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lyr.definitionQuery = defquery&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Jan 2013 13:16:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/add-definition-query-to-all-layers-in-mxd-that/m-p/595864#M46637</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2013-01-29T13:16:05Z</dc:date>
    </item>
    <item>
      <title>Re: Add Definition Query to all Layers in MXD that reside in SDE only</title>
      <link>https://community.esri.com/t5/python-questions/add-definition-query-to-all-layers-in-mxd-that/m-p/595865#M46638</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thats it! Thanks&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Jan 2013 15:09:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/add-definition-query-to-all-layers-in-mxd-that/m-p/595865#M46638</guid>
      <dc:creator>jamesborris</dc:creator>
      <dc:date>2013-01-29T15:09:38Z</dc:date>
    </item>
  </channel>
</rss>

