<?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 to run complex SQL query in Alteryx Server Discussions</title>
    <link>https://community.alteryx.com/t5/Alteryx-Server-Discussions/How-to-run-complex-SQL-query/m-p/533405#M5801</link>
    <description>&lt;P&gt;Hi Everyone,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We are trying to use Alteryx to run a complex SQL query. Please see the code below. The query will create a table, then call a stored procedure and select all data to the table as last step. Does anyone has done something similar in the past ? Any suggestions on how to run this query thru Alteryx ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;USE [ABC]&lt;BR /&gt;GO&lt;/P&gt;&lt;P&gt;DECLARE @DateFrom date = '2019-12-01';&lt;BR /&gt;DECLARE @DateTo date = '2019-12-31';&lt;BR /&gt;DECLARE @PGID numeric(18,0) = 146;&lt;BR /&gt;DECLARE @OID numeric(18,0) = NULL;&lt;/P&gt;&lt;P&gt;CREATE TABLE #income_allocation&lt;BR /&gt;(&lt;BR /&gt;PGID numeric(18, 0) NOT NULL,&lt;BR /&gt;OID numeric(18, 0) NOT NULL,&lt;BR /&gt;clinic_id smallint NOT NULL,&lt;BR /&gt;provider_id numeric(18, 0) NOT NULL,&lt;BR /&gt;location_id numeric(18, 0) NULL,&lt;BR /&gt;date_start smalldatetime NULL,&lt;BR /&gt;date_end smalldatetime NULL,&lt;BR /&gt;beginning_balance money NULL&lt;BR /&gt;);&lt;/P&gt;&lt;P&gt;INSERT #income_allocation&lt;BR /&gt;EXECUTE dbo.usp_stored_procedure1&lt;BR /&gt;@DateFrom&lt;BR /&gt;,@DateTo&lt;BR /&gt;,@PGID&lt;BR /&gt;,@OID&lt;/P&gt;&lt;P&gt;select * from #income_allocation&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 26 Feb 2020 04:26:40 GMT</pubDate>
    <dc:creator>Chriszou</dc:creator>
    <dc:date>2020-02-26T04:26:40Z</dc:date>
    <item>
      <title>How to run complex SQL query</title>
      <link>https://community.alteryx.com/t5/Alteryx-Server-Discussions/How-to-run-complex-SQL-query/m-p/533405#M5801</link>
      <description>&lt;P&gt;Hi Everyone,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We are trying to use Alteryx to run a complex SQL query. Please see the code below. The query will create a table, then call a stored procedure and select all data to the table as last step. Does anyone has done something similar in the past ? Any suggestions on how to run this query thru Alteryx ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;USE [ABC]&lt;BR /&gt;GO&lt;/P&gt;&lt;P&gt;DECLARE @DateFrom date = '2019-12-01';&lt;BR /&gt;DECLARE @DateTo date = '2019-12-31';&lt;BR /&gt;DECLARE @PGID numeric(18,0) = 146;&lt;BR /&gt;DECLARE @OID numeric(18,0) = NULL;&lt;/P&gt;&lt;P&gt;CREATE TABLE #income_allocation&lt;BR /&gt;(&lt;BR /&gt;PGID numeric(18, 0) NOT NULL,&lt;BR /&gt;OID numeric(18, 0) NOT NULL,&lt;BR /&gt;clinic_id smallint NOT NULL,&lt;BR /&gt;provider_id numeric(18, 0) NOT NULL,&lt;BR /&gt;location_id numeric(18, 0) NULL,&lt;BR /&gt;date_start smalldatetime NULL,&lt;BR /&gt;date_end smalldatetime NULL,&lt;BR /&gt;beginning_balance money NULL&lt;BR /&gt;);&lt;/P&gt;&lt;P&gt;INSERT #income_allocation&lt;BR /&gt;EXECUTE dbo.usp_stored_procedure1&lt;BR /&gt;@DateFrom&lt;BR /&gt;,@DateTo&lt;BR /&gt;,@PGID&lt;BR /&gt;,@OID&lt;/P&gt;&lt;P&gt;select * from #income_allocation&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Feb 2020 04:26:40 GMT</pubDate>
      <guid>https://community.alteryx.com/t5/Alteryx-Server-Discussions/How-to-run-complex-SQL-query/m-p/533405#M5801</guid>
      <dc:creator>Chriszou</dc:creator>
      <dc:date>2020-02-26T04:26:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to run complex SQL query</title>
      <link>https://community.alteryx.com/t5/Alteryx-Server-Discussions/How-to-run-complex-SQL-query/m-p/533531#M5803</link>
      <description>&lt;P&gt;When I needed Alteryx to run a dynamically generated create view sql, I saved the sql script as a file and used run cmd tool to run a python program that input the file and ran the script. There's a command line option for all databases that might be used instead of python. The python tool has improved since I did this and may work better than the run command tool I used.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Feb 2020 12:53:23 GMT</pubDate>
      <guid>https://community.alteryx.com/t5/Alteryx-Server-Discussions/How-to-run-complex-SQL-query/m-p/533531#M5803</guid>
      <dc:creator>hroderick-thr</dc:creator>
      <dc:date>2020-02-26T12:53:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to run complex SQL query</title>
      <link>https://community.alteryx.com/t5/Alteryx-Server-Discussions/How-to-run-complex-SQL-query/m-p/533574#M5810</link>
      <description>&lt;P&gt;Thanks for your idea. Is it possible you could share a sample workflow ? Also have a associated question. If the sql stored process have a few parameters and these parameters need to be changed in every run. How would you recommend to handle this ? (i.e. how to update the parameter at every run and feed to SQL from Alteryx). Thank you very much&lt;/P&gt;</description>
      <pubDate>Wed, 26 Feb 2020 14:41:59 GMT</pubDate>
      <guid>https://community.alteryx.com/t5/Alteryx-Server-Discussions/How-to-run-complex-SQL-query/m-p/533574#M5810</guid>
      <dc:creator>Chriszou</dc:creator>
      <dc:date>2020-02-26T14:41:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to run complex SQL query</title>
      <link>https://community.alteryx.com/t5/Alteryx-Server-Discussions/How-to-run-complex-SQL-query/m-p/533597#M5814</link>
      <description>&lt;P&gt;I'm sorry but I don't have time to build an example and I can't share my examples from work.&lt;/P&gt;&lt;P&gt;Here's an outline of what you need to do....&lt;/P&gt;&lt;P&gt;1. Get command line tool for your database working in the environment it will be running (desktop, server, worker, etc)&lt;/P&gt;&lt;P&gt;2. Create a&amp;nbsp;bat file that uses the command line tool to run your stored procedure with hardcoded parameters&lt;/P&gt;&lt;P&gt;3. Use Alteryx to create a bat file like you tested in 2, except with dynamic parameters&lt;/P&gt;&lt;P&gt;4. Use Alteryx &lt;EM&gt;Run&lt;/EM&gt; &lt;EM&gt;Command &lt;/EM&gt;tool to run the bat file you created in 3.&lt;/P&gt;&lt;P&gt;Tip: Put 3 and 4 in separate workflows and use Crew Runner macro to run them in order.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Feb 2020 15:26:43 GMT</pubDate>
      <guid>https://community.alteryx.com/t5/Alteryx-Server-Discussions/How-to-run-complex-SQL-query/m-p/533597#M5814</guid>
      <dc:creator>hroderick-thr</dc:creator>
      <dc:date>2020-02-26T15:26:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to run complex SQL query</title>
      <link>https://community.alteryx.com/t5/Alteryx-Server-Discussions/How-to-run-complex-SQL-query/m-p/533614#M5815</link>
      <description>&lt;P&gt;Thank you for the advice. I will give it a shot. Again, thank you.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Feb 2020 15:44:51 GMT</pubDate>
      <guid>https://community.alteryx.com/t5/Alteryx-Server-Discussions/How-to-run-complex-SQL-query/m-p/533614#M5815</guid>
      <dc:creator>Chriszou</dc:creator>
      <dc:date>2020-02-26T15:44:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to run complex SQL query</title>
      <link>https://community.alteryx.com/t5/Alteryx-Server-Discussions/How-to-run-complex-SQL-query/m-p/533621#M5816</link>
      <description>&lt;P&gt;Best wishes for success. If you get it working I'd love go get my first solved credit on this forum&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Given a bit of encouragement I&amp;nbsp;try some evening&amp;nbsp;work to build a python based sql tool for the gallery.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Feb 2020 15:57:52 GMT</pubDate>
      <guid>https://community.alteryx.com/t5/Alteryx-Server-Discussions/How-to-run-complex-SQL-query/m-p/533621#M5816</guid>
      <dc:creator>hroderick-thr</dc:creator>
      <dc:date>2020-02-26T15:57:52Z</dc:date>
    </item>
  </channel>
</rss>

