<?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 arcpy.ArcSDESQLExecute returning Boolean for EXEC SQL Statement? in Data Management Questions</title>
    <link>https://community.esri.com/t5/data-management-questions/arcpy-arcsdesqlexecute-returning-boolean-for-exec/m-p/758115#M42597</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to call a stored procedure using arcpy.ArcSDESQLExecute to retrieve a single record. In MSSQL I can call the stored procedure and I get the expected value. When I use arcpy.ArcSDESQLExecute to execute the stored procedure I get a Boolean True value.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;sdeConn.execute('EXEC dbo.usp_GetValue;') //Always returns true&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Has anyone ever encountered this problem before.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 29 Aug 2014 14:38:21 GMT</pubDate>
    <dc:creator>TomasWoods</dc:creator>
    <dc:date>2014-08-29T14:38:21Z</dc:date>
    <item>
      <title>arcpy.ArcSDESQLExecute returning Boolean for EXEC SQL Statement?</title>
      <link>https://community.esri.com/t5/data-management-questions/arcpy-arcsdesqlexecute-returning-boolean-for-exec/m-p/758115#M42597</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to call a stored procedure using arcpy.ArcSDESQLExecute to retrieve a single record. In MSSQL I can call the stored procedure and I get the expected value. When I use arcpy.ArcSDESQLExecute to execute the stored procedure I get a Boolean True value.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;sdeConn.execute('EXEC dbo.usp_GetValue;') //Always returns true&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Has anyone ever encountered this problem before.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Aug 2014 14:38:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/arcpy-arcsdesqlexecute-returning-boolean-for-exec/m-p/758115#M42597</guid>
      <dc:creator>TomasWoods</dc:creator>
      <dc:date>2014-08-29T14:38:21Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.ArcSDESQLExecute returning Boolean for EXEC SQL Statement?</title>
      <link>https://community.esri.com/t5/data-management-questions/arcpy-arcsdesqlexecute-returning-boolean-for-exec/m-p/758116#M42598</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I also have this problem. I am executing a simply "SELECT column FROM table WHERE column='something'" and I am being returned True, even though the correct response is 2 rows of data. Anyone?&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Nov 2016 18:16:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/arcpy-arcsdesqlexecute-returning-boolean-for-exec/m-p/758116#M42598</guid>
      <dc:creator>TomGiles</dc:creator>
      <dc:date>2016-11-03T18:16:16Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.ArcSDESQLExecute returning Boolean for EXEC SQL Statement?</title>
      <link>https://community.esri.com/t5/data-management-questions/arcpy-arcsdesqlexecute-returning-boolean-for-exec/m-p/758117#M42599</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Are you querying against versioned or unversioned tables?&amp;nbsp; It appears the WHERE statement is against a text field, correct?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Nov 2016 18:58:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/arcpy-arcsdesqlexecute-returning-boolean-for-exec/m-p/758117#M42599</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2016-11-03T18:58:15Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.ArcSDESQLExecute returning Boolean for EXEC SQL Statement?</title>
      <link>https://community.esri.com/t5/data-management-questions/arcpy-arcsdesqlexecute-returning-boolean-for-exec/m-p/758118#M42600</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It is an unversioned feature class. I am using direct connect. The where statement does execute against a text field of Hash IDs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note: I have gotten around this by dropping Arcpy and using pymssql - it works and the overhead is pretty small. I would still be interested in hearing why I am being returned True (which is supposed to be returned in cases where no records are returned)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Nov 2016 19:23:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/arcpy-arcsdesqlexecute-returning-boolean-for-exec/m-p/758118#M42600</guid>
      <dc:creator>TomGiles</dc:creator>
      <dc:date>2016-11-03T19:23:15Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.ArcSDESQLExecute returning Boolean for EXEC SQL Statement?</title>
      <link>https://community.esri.com/t5/data-management-questions/arcpy-arcsdesqlexecute-returning-boolean-for-exec/m-p/758119#M42601</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can you get any query to work using arcpy.ArcSDESQLExecute or is it just this specific query that is having issues?&amp;nbsp; What data type, specifically, is the hash ID field?&amp;nbsp; Are any special characters used in the hashes, specifically backslashes?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Nov 2016 19:55:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/arcpy-arcsdesqlexecute-returning-boolean-for-exec/m-p/758119#M42601</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2016-11-03T19:55:21Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.ArcSDESQLExecute returning Boolean for EXEC SQL Statement?</title>
      <link>https://community.esri.com/t5/data-management-questions/arcpy-arcsdesqlexecute-returning-boolean-for-exec/m-p/758120#M42602</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-classes/arcsdesqlexecute.htm"&gt;arcpy.ArcSDESQLExecute()&lt;/A&gt; returns a boolean TRUE if a select statement was valid but no rows were returned. In your case, you're executing a procedure and I think it's just telling you the procedure ran successfully.&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;...for statements that do not return rows, it will return an indication of the success or failure of the statement (True for success; None for failure).&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Maybe try reformatting your SQL into a select statement to trick it into expecting rows back.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Nov 2016 20:01:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/arcpy-arcsdesqlexecute-returning-boolean-for-exec/m-p/758120#M42602</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2016-11-03T20:01:13Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.ArcSDESQLExecute returning Boolean for EXEC SQL Statement?</title>
      <link>https://community.esri.com/t5/data-management-questions/arcpy-arcsdesqlexecute-returning-boolean-for-exec/m-p/758121#M42603</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for your help walking me through this. A little embarrassing, I rewrote the stub and it is working fine. This script isn't on git so unfortunately I cannot back track. It's curious I found the original post here, I now wonder what I/we were doing; it must have been a typo.&amp;nbsp;Note, it wasn't a procedure but good call on that behaviour.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Very simple, as the sample goes..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; arcpy

&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"Connecting to SQL Server.."&lt;/SPAN&gt;
sqlConn &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ArcSDESQLExecute&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;r&lt;SPAN class="string token"&gt;"\\gismsa\...\sde@iSphereBuoys.sde"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

table_name &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'iSphereBuoys'&lt;/SPAN&gt;
field_name &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'hashId'&lt;/SPAN&gt;

sql &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'''
SELECT {0} FROM {1} WHERE {0}='943906c71d6c93c7a2515b33d7a5be65'
'''&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;format&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;field_name&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; table_name&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

sqlReturn &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; sqlConn&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;execute&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;sql&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; sqlReturn
&lt;SPAN class="comment token"&gt;#or&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; i &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; sqlReturn&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; i‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 08:08:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/arcpy-arcsdesqlexecute-returning-boolean-for-exec/m-p/758121#M42603</guid>
      <dc:creator>TomGiles</dc:creator>
      <dc:date>2021-12-12T08:08:20Z</dc:date>
    </item>
  </channel>
</rss>

