<?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: Definition query causes SQL error when published in map service in ArcGIS Enterprise Questions</title>
    <link>https://community.esri.com/t5/arcgis-enterprise-questions/definition-query-causes-sql-error-when-published/m-p/354054#M13661</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In SQL, it's an int field. It's a domained attribute, so in the query builder, when I choose 'get unique values' it comes back with (for example) '1 - Pond'; '2 - Lake', and when I double click on a single value, it puts a '1' (without apostrophes into the SQL query. But like I say, in the actual SQL table, it's an int&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 18 Dec 2018 17:12:36 GMT</pubDate>
    <dc:creator>JonathanLathigee</dc:creator>
    <dc:date>2018-12-18T17:12:36Z</dc:date>
    <item>
      <title>Definition query causes SQL error when published in map service</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/definition-query-causes-sql-error-when-published/m-p/354052#M13659</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I created an mxd with 2 layers. One layer has the definition query:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SHAPE.STArea() &amp;gt; 400000&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The second layer has the definition query:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Subtype IN (1,2,3) and Shape.STArea() &amp;gt; 2000&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Both of these definition queries were built in the query builder, verified with no errors, and then I inspected the attribute tables for the 2 layers and confirmed that the queries were correctly filtering the data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I shared the mxd as a service, and analyzed it before publishing with no errors.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;On querying the service, layer one returns:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE width="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD style="border: solid windowtext 1.0pt; background: #E5EDF4; padding: 2.25pt 3.75pt 2.25pt 3.75pt;" width="65"&gt;&lt;P&gt;&lt;SPAN style="font-size: 9.0pt; color: #505051;"&gt;SEVERE&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD style="border: solid windowtext 1.0pt; background: #E5EDF4; padding: 2.25pt 3.75pt 2.25pt 3.75pt;" width="140"&gt;&lt;P&gt;&lt;SPAN style="font-size: 9.0pt; color: #505051;"&gt;Dec 17, 2018, 3:44:15 PM&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD style="border: solid windowtext 1.0pt; background: #E5EDF4; padding: 2.25pt 3.75pt 2.25pt 3.75pt;" width="387"&gt;&lt;P&gt;&lt;SPAN style="font-size: 9.0pt; color: #505051;"&gt;Geodatabase error: Underlying DBMS error [[Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Incorrect syntax near ')'.] [GISPRD.DBO.hyd_Poly].&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD style="border: solid windowtext 1.0pt; background: #E5EDF4; padding: 2.25pt 3.75pt 2.25pt 3.75pt;" width="330"&gt;&lt;P&gt;&lt;SPAN style="font-size: 9.0pt; color: #505051;"&gt;Testing/201812LakesOne.MapServer&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And layer 2 returns:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE width="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD style="border: solid windowtext 1.0pt; background: #CEE6FA; padding: 2.25pt 3.75pt 2.25pt 3.75pt;" width="65"&gt;&lt;P&gt;&lt;SPAN style="font-size: 9.0pt; color: #505051;"&gt;SEVERE&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD style="border: solid windowtext 1.0pt; background: #CEE6FA; padding: 2.25pt 3.75pt 2.25pt 3.75pt;" width="140"&gt;&lt;P&gt;&lt;SPAN style="font-size: 9.0pt; color: #505051;"&gt;Dec 17, 2018, 3:51:46 PM&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD style="border: solid windowtext 1.0pt; background: #CEE6FA; padding: 2.25pt 3.75pt 2.25pt 3.75pt;" width="387"&gt;&lt;P&gt;&lt;SPAN style="font-size: 9.0pt; color: #505051;"&gt;Geodatabase error: Underlying DBMS error [[Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Incorrect syntax near '1'.] [GISPRD.DBO.hyd_Poly].&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD style="border: solid windowtext 1.0pt; background: #CEE6FA; padding: 2.25pt 3.75pt 2.25pt 3.75pt;" width="330"&gt;&lt;P&gt;&lt;SPAN style="font-size: 9.0pt; color: #505051;"&gt;Testing/201812LakesOne.MapServer&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Update the definition queries as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Layer 1:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;[SHAPE].STArea() &amp;gt; 400000&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(ie square brackets)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Layer 2:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Subtype IN ( '1' , '2' , '3' ) AND [SHAPE].STArea() &amp;gt;2000&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(ie escape ‘in’ values with apostrophes and square brackets).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now both layers can be queried correctly&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you please explain what’s going on here? And where can I find some documentation to avoid these kinds of pitfalls when publishing services?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ArcMap 10.2.2.3552; ArcServer 10.41&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt;"&gt;Thank you&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Dec 2018 16:51:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/definition-query-causes-sql-error-when-published/m-p/354052#M13659</guid>
      <dc:creator>JonathanLathigee</dc:creator>
      <dc:date>2018-12-18T16:51:08Z</dc:date>
    </item>
    <item>
      <title>Re: Definition query causes SQL error when published in map service</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/definition-query-causes-sql-error-when-published/m-p/354053#M13660</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What data type is "Subtype"?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Dec 2018 17:08:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/definition-query-causes-sql-error-when-published/m-p/354053#M13660</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2018-12-18T17:08:51Z</dc:date>
    </item>
    <item>
      <title>Re: Definition query causes SQL error when published in map service</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/definition-query-causes-sql-error-when-published/m-p/354054#M13661</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In SQL, it's an int field. It's a domained attribute, so in the query builder, when I choose 'get unique values' it comes back with (for example) '1 - Pond'; '2 - Lake', and when I double click on a single value, it puts a '1' (without apostrophes into the SQL query. But like I say, in the actual SQL table, it's an int&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Dec 2018 17:12:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/definition-query-causes-sql-error-when-published/m-p/354054#M13661</guid>
      <dc:creator>JonathanLathigee</dc:creator>
      <dc:date>2018-12-18T17:12:36Z</dc:date>
    </item>
  </channel>
</rss>

