<?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 How can I create tables in ArcMap using SQL and/or Scripting? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/how-can-i-create-tables-in-arcmap-using-sql-and-or/m-p/286676#M22169</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am interested in creating a queried table/report within ArcMap using SQL and/or a scripting language (python, perhaps). Can anyone suggest an approach or resources&amp;nbsp;to get this done? Eventually, I'd like to have this as part of a model.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is what I can do:&lt;/P&gt;&lt;P&gt;I can create a table using&amp;nbsp;SQL in Microsoft SQL Server Management Studio of an enterprise database.&amp;nbsp; Here is a query that works in Management Studio:&lt;/P&gt;&lt;P&gt;select substring(MAP_ZONING, 1, 3) as ZONING, sum((Shape_Area/43560)) as Acres, COUNT(MAP_ZONING) as Frequency&lt;BR /&gt;from [EnterpriseDatabase]&lt;BR /&gt;where MAP_ZONING is not null and ExLandUse = 'VACANT'&lt;BR /&gt;group by substring(MAP_ZONING, 1, 3)&lt;BR /&gt;order by ZONING&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note: I need only the first three characters of the values in the MAP_ZONING, thus the "substring" function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is what I'd like to do:&lt;/P&gt;&lt;P&gt;Create a similar table, but querying a feature class that is in a file geodatabase not an enterprise geodatabase on a server.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have tried the MakeQueryTable geoprocessing tool, but there are limitations I can't seem to work around.&amp;nbsp; One is that the "Query Builder" GUI seems to only like selecting all records after a where clause, and will not accept a query like the one above.&amp;nbsp; I have tried to figure out if I can put my query in a subquery to get it to work, but have had no success.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think this could be done using a python script, but I am a beginner and need to find some examples and resources.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Chip&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 19 Apr 2018 15:41:28 GMT</pubDate>
    <dc:creator>ChipBrownHBG</dc:creator>
    <dc:date>2018-04-19T15:41:28Z</dc:date>
    <item>
      <title>How can I create tables in ArcMap using SQL and/or Scripting?</title>
      <link>https://community.esri.com/t5/python-questions/how-can-i-create-tables-in-arcmap-using-sql-and-or/m-p/286676#M22169</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am interested in creating a queried table/report within ArcMap using SQL and/or a scripting language (python, perhaps). Can anyone suggest an approach or resources&amp;nbsp;to get this done? Eventually, I'd like to have this as part of a model.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is what I can do:&lt;/P&gt;&lt;P&gt;I can create a table using&amp;nbsp;SQL in Microsoft SQL Server Management Studio of an enterprise database.&amp;nbsp; Here is a query that works in Management Studio:&lt;/P&gt;&lt;P&gt;select substring(MAP_ZONING, 1, 3) as ZONING, sum((Shape_Area/43560)) as Acres, COUNT(MAP_ZONING) as Frequency&lt;BR /&gt;from [EnterpriseDatabase]&lt;BR /&gt;where MAP_ZONING is not null and ExLandUse = 'VACANT'&lt;BR /&gt;group by substring(MAP_ZONING, 1, 3)&lt;BR /&gt;order by ZONING&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note: I need only the first three characters of the values in the MAP_ZONING, thus the "substring" function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is what I'd like to do:&lt;/P&gt;&lt;P&gt;Create a similar table, but querying a feature class that is in a file geodatabase not an enterprise geodatabase on a server.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have tried the MakeQueryTable geoprocessing tool, but there are limitations I can't seem to work around.&amp;nbsp; One is that the "Query Builder" GUI seems to only like selecting all records after a where clause, and will not accept a query like the one above.&amp;nbsp; I have tried to figure out if I can put my query in a subquery to get it to work, but have had no success.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think this could be done using a python script, but I am a beginner and need to find some examples and resources.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Chip&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Apr 2018 15:41:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-can-i-create-tables-in-arcmap-using-sql-and-or/m-p/286676#M22169</guid>
      <dc:creator>ChipBrownHBG</dc:creator>
      <dc:date>2018-04-19T15:41:28Z</dc:date>
    </item>
    <item>
      <title>Re: How can I create tables in ArcMap using SQL and/or Scripting?</title>
      <link>https://community.esri.com/t5/python-questions/how-can-i-create-tables-in-arcmap-using-sql-and-or/m-p/286677#M22170</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Select by Attributes followed by a Copy Features... see the script examples&lt;/P&gt;&lt;P&gt;&lt;A href="http://pro.arcgis.com/en/pro-app/tool-reference/data-management/select-layer-by-attribute.htm"&gt;http://pro.arcgis.com/en/pro-app/tool-reference/data-management/select-layer-by-attribute.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://pro.arcgis.com/en/pro-app/tool-reference/data-management/copy-features.htm"&gt;http://pro.arcgis.com/en/pro-app/tool-reference/data-management/copy-features.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;you should be able to cobble a separate script or model from these.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Apr 2018 18:05:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-can-i-create-tables-in-arcmap-using-sql-and-or/m-p/286677#M22170</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2018-04-19T18:05:43Z</dc:date>
    </item>
    <item>
      <title>Re: How can I create tables in ArcMap using SQL and/or Scripting?</title>
      <link>https://community.esri.com/t5/python-questions/how-can-i-create-tables-in-arcmap-using-sql-and-or/m-p/286678#M22171</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, Dan.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have the part about creating the model by using the select by layer and copy features, what I am stuck on is how to create a queried table that contains just the information (columns, summarized records, etc) that I am looking for.&amp;nbsp; As I said above, when the I am using a table that is accessible through Microsoft SQL Server Management studio, I can create the table easily.&amp;nbsp; I am looking for any resources to be able to query the copied features that are in a local file geodatabase. I think the query is too complicated to use in the "Query Builder" GUI in ArcMap (10.5 or Pro) and think it might be a candidate for a python script.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thoughts? Resources for building SQL queries in a python script and then adding these to a model?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Apr 2018 12:57:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-can-i-create-tables-in-arcmap-using-sql-and-or/m-p/286678#M22171</guid>
      <dc:creator>ChipBrownHBG</dc:creator>
      <dc:date>2018-04-24T12:57:23Z</dc:date>
    </item>
  </channel>
</rss>

