<?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: How to use WITH Clause in Query Layer in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/how-to-use-with-clause-in-query-layer/m-p/1670689#M100615</link>
    <description>&lt;P&gt;I have found table-valued functions to be the best way to sneak non vanilla SQL into Pro.&amp;nbsp; Lets me use CTEs and things like ROW_NUMBER to create unique ids.&lt;/P&gt;</description>
    <pubDate>Thu, 04 Dec 2025 20:56:36 GMT</pubDate>
    <dc:creator>JeffHaney</dc:creator>
    <dc:date>2025-12-04T20:56:36Z</dc:date>
    <item>
      <title>How to use WITH Clause in Query Layer</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/how-to-use-with-clause-in-query-layer/m-p/1662057#M99840</link>
      <description>&lt;P&gt;I have query that uses common tables via a WITH clause. It works fine in SSMS, but doesn't seem to run in the Add Query Layer tool. Simple example below:&lt;/P&gt;&lt;LI-CODE lang="sql"&gt;WITH my_cte AS (
    SELECT *
    FROM my_table
)
SELECT *
FROM my_cte&lt;/LI-CODE&gt;&lt;LI-CODE lang="sql"&gt; Invalid SQL syntax[[Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Incorrect syntax near the keyword 'WITH'.]&lt;/LI-CODE&gt;&lt;P&gt;Is there some sort of restriction or syntax difference for CTE tables in ArcGIS Pro?&lt;/P&gt;&lt;P&gt;This query is being run against a separate SQL Server 2022 database via an SDE connection, not an Enterprise Geodatabase.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Oct 2025 21:41:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/how-to-use-with-clause-in-query-layer/m-p/1662057#M99840</guid>
      <dc:creator>cjms</dc:creator>
      <dc:date>2025-10-29T21:41:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to use WITH Clause in Query Layer</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/how-to-use-with-clause-in-query-layer/m-p/1662258#M99863</link>
      <description>&lt;P&gt;Not sure why that keyword specifically is causing issues but you can rewrite that as:&lt;/P&gt;&lt;LI-CODE lang="sql"&gt;SELECT a.*
FROM (SELECT * FROM my_table) a&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 30 Oct 2025 16:12:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/how-to-use-with-clause-in-query-layer/m-p/1662258#M99863</guid>
      <dc:creator>DavidSolari</dc:creator>
      <dc:date>2025-10-30T16:12:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to use WITH Clause in Query Layer</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/how-to-use-with-clause-in-query-layer/m-p/1662368#M99870</link>
      <description>&lt;P&gt;I'm aware subqueries work. I was just hoping not to have to refactor; I think the CTE looks more readable for longer queries.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Oct 2025 22:30:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/how-to-use-with-clause-in-query-layer/m-p/1662368#M99870</guid>
      <dc:creator>cjms</dc:creator>
      <dc:date>2025-10-30T22:30:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to use WITH Clause in Query Layer</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/how-to-use-with-clause-in-query-layer/m-p/1662502#M99879</link>
      <description>&lt;P&gt;I agree about CTE.&amp;nbsp; I suggest you submit an ArcGIS Pro Idea to support using CTE with SQL Server query layers.&lt;/P&gt;</description>
      <pubDate>Fri, 31 Oct 2025 14:53:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/how-to-use-with-clause-in-query-layer/m-p/1662502#M99879</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2025-10-31T14:53:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to use WITH Clause in Query Layer</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/how-to-use-with-clause-in-query-layer/m-p/1670689#M100615</link>
      <description>&lt;P&gt;I have found table-valued functions to be the best way to sneak non vanilla SQL into Pro.&amp;nbsp; Lets me use CTEs and things like ROW_NUMBER to create unique ids.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Dec 2025 20:56:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/how-to-use-with-clause-in-query-layer/m-p/1670689#M100615</guid>
      <dc:creator>JeffHaney</dc:creator>
      <dc:date>2025-12-04T20:56:36Z</dc:date>
    </item>
  </channel>
</rss>

