<?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 Stored Procedure call in esri python in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/stored-procedure-call-in-esri-python/m-p/742450#M57370</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I want to run a stored procedure prepared in the&amp;nbsp;mssql&amp;nbsp;Over the ESRI python&lt;/P&gt;&lt;P&gt;I wrote a code like this, but I get an error on the last line&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;# Create connection&lt;BR /&gt;arcpy.ArcSDESQLExecute(server='172.16.200.16', instance='sde:sqlserver:172.16.200.16', database='BYS', user='cbssa',password='Adm18712')&lt;BR /&gt;# Execute stored procedure&lt;BR /&gt;sql = "EXEC dbo.MyStoredProcedure @id = uSP_DB_IslemYap_CELIKVANA"&lt;BR /&gt;db_connection.execute(sql)&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 15 May 2017 13:43:05 GMT</pubDate>
    <dc:creator>GIS_Solutions</dc:creator>
    <dc:date>2017-05-15T13:43:05Z</dc:date>
    <item>
      <title>Stored Procedure call in esri python</title>
      <link>https://community.esri.com/t5/python-questions/stored-procedure-call-in-esri-python/m-p/742450#M57370</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I want to run a stored procedure prepared in the&amp;nbsp;mssql&amp;nbsp;Over the ESRI python&lt;/P&gt;&lt;P&gt;I wrote a code like this, but I get an error on the last line&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;# Create connection&lt;BR /&gt;arcpy.ArcSDESQLExecute(server='172.16.200.16', instance='sde:sqlserver:172.16.200.16', database='BYS', user='cbssa',password='Adm18712')&lt;BR /&gt;# Execute stored procedure&lt;BR /&gt;sql = "EXEC dbo.MyStoredProcedure @id = uSP_DB_IslemYap_CELIKVANA"&lt;BR /&gt;db_connection.execute(sql)&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 May 2017 13:43:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/stored-procedure-call-in-esri-python/m-p/742450#M57370</guid>
      <dc:creator>GIS_Solutions</dc:creator>
      <dc:date>2017-05-15T13:43:05Z</dc:date>
    </item>
    <item>
      <title>Re: Stored Procedure call in esri python</title>
      <link>https://community.esri.com/t5/python-questions/stored-procedure-call-in-esri-python/m-p/742451#M57371</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You did not assign the db_connection. &amp;nbsp;Try&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="comment token"&gt;# Create connection&lt;/SPAN&gt;
db_connection &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;server&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'172.16.200.16'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; instance&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'sde:sqlserver:172.16.200.16'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; database&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'BYS'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; user&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'cbssa'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;password&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'Adm18712'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;# Execute stored procedure&lt;/SPAN&gt;
sql &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"EXEC dbo.MyStoredProcedure @id = uSP_DB_IslemYap_CELIKVANA"&lt;/SPAN&gt;
db_connection&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="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;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 07:36:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/stored-procedure-call-in-esri-python/m-p/742451#M57371</guid>
      <dc:creator>KevinDunlop</dc:creator>
      <dc:date>2021-12-12T07:36:01Z</dc:date>
    </item>
    <item>
      <title>Re: Stored Procedure call in esri python</title>
      <link>https://community.esri.com/t5/python-questions/stored-procedure-call-in-esri-python/m-p/742452#M57372</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Kevin for reply&lt;/P&gt;&lt;P&gt;I made the change and this time I get the error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="image-1 jive-image j-img-original" src="/legacyfs/online/351217_stored procedure1.jpg" style="width: 620px; height: 367px;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 May 2017 07:47:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/stored-procedure-call-in-esri-python/m-p/742452#M57372</guid>
      <dc:creator>GIS_Solutions</dc:creator>
      <dc:date>2017-05-16T07:47:26Z</dc:date>
    </item>
    <item>
      <title>Re: Stored Procedure call in esri python</title>
      <link>https://community.esri.com/t5/python-questions/stored-procedure-call-in-esri-python/m-p/742453#M57373</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Create a sde file from you database connection string and you can call stored procedure as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sde_Conn = arcpy.ArcSDESQLExecute(&lt;STRONG&gt;DBConnection.sde&lt;/STRONG&gt;)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For Oracle&lt;BR /&gt;sde_Conn.execute("call dbo.MyStoredProcedure(uSP_DB_IslemYap_CELIKVANA)")&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I found this information in another discussion but unfortunately I could not locate the link. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For SQL Server&lt;/P&gt;&lt;P&gt;sde_Conn.execute("exec dbo.MyStoredProcedure(uSP_DB_IslemYap_CELIKVANA)")&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 May 2017 21:14:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/stored-procedure-call-in-esri-python/m-p/742453#M57373</guid>
      <dc:creator>sapnas</dc:creator>
      <dc:date>2017-05-18T21:14:45Z</dc:date>
    </item>
    <item>
      <title>Re: Stored Procedure call in esri python</title>
      <link>https://community.esri.com/t5/python-questions/stored-procedure-call-in-esri-python/m-p/742454#M57374</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;We have been running stored procedures using the method shown above, but it is no longer working since upgrading SQL from 2008 to 2014.&amp;nbsp; We now get an error stating that &lt;SPAN style="color: #222222; background-color: #ffffff; font-size: 16px;"&gt;“&lt;/SPAN&gt;&lt;STRONG style="color: #222222; background-color: #ffffff; font-size: 16px;"&gt;The metadata could not be determined because statement...uses a temporary table."&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Any suggestions or a work-around to get our existing stored procedures to run from python scripts?&amp;nbsp; Is there a better approach rather than using arcpy.ArcSDESQLExecute to run a stored procedure?&lt;/P&gt;&lt;P&gt;Thanks in advance,&lt;/P&gt;&lt;P&gt;Stephanie&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Nov 2017 18:42:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/stored-procedure-call-in-esri-python/m-p/742454#M57374</guid>
      <dc:creator>StephanieWidas1</dc:creator>
      <dc:date>2017-11-08T18:42:34Z</dc:date>
    </item>
    <item>
      <title>Re: Stored Procedure call in esri python</title>
      <link>https://community.esri.com/t5/python-questions/stored-procedure-call-in-esri-python/m-p/742455#M57375</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The way to call stored procedures from ArcPy has &lt;STRONG&gt;not&lt;/STRONG&gt; changed with SQL Server 2014. I work on a project that runs the stored procedure using&lt;/P&gt;&lt;PRE class="language-python line-numbers"&gt;&lt;CODE&gt;sde_Conn&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;execute&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;"&lt;SPAN class="keyword token"&gt;exec&lt;/SPAN&gt; dbo&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;MyStoredProcedure&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;in SQL Server 2014.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The error you are getting is due to a difference in the way SQL Server fetches metadata starting with SQL Server 2012. A quick web search reveals several possible solution.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You may be able to resolve this issue by replacing the temporary table with a &lt;A href="https://technet.microsoft.com/en-us/library/ms190766(v=sql.105).aspx"&gt;Common Table Expression&lt;/A&gt; or a &lt;A href="https://docs.microsoft.com/en-us/sql/t-sql/data-types/table-transact-sql"&gt;Table Variable&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There could also be issues with your returned dataset (if you're returning anything). I know the &lt;EM&gt;WITH RESULTS SETS &lt;/EM&gt;syntax allows you to explicitly set the format, but I'm not particularly familiar with it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Nov 2017 21:02:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/stored-procedure-call-in-esri-python/m-p/742455#M57375</guid>
      <dc:creator>DavidBlanchard</dc:creator>
      <dc:date>2017-11-15T21:02:13Z</dc:date>
    </item>
  </channel>
</rss>

