<?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: Multiple statements in SQL query in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Multiple-statements-in-SQL-query/m-p/623101#M683628</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Using server side stored procedures and calling them from the QlikView script including passing variables definitely works.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 24 Feb 2014 12:13:41 GMT</pubDate>
    <dc:creator>simondachstr</dc:creator>
    <dc:date>2014-02-24T12:13:41Z</dc:date>
    <item>
      <title>Multiple statements in SQL query</title>
      <link>https://community.qlik.com/t5/QlikView/Multiple-statements-in-SQL-query/m-p/623100#M683627</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&amp;nbsp; I have a quick question, which I suspect the answer to is No.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you, in Qlikview, directly execute SQL statements like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;--------------------&lt;/P&gt;&lt;P&gt;LOAD *;&lt;/P&gt;&lt;P&gt;SQL&lt;/P&gt;&lt;P&gt;declare @maxdate date;&lt;/P&gt;&lt;P&gt;select @maxdate =&amp;nbsp; max(MyColumn) from Holdings&lt;/P&gt;&lt;P&gt;select * from AnotherTable Where Column &amp;lt; @maxdate;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;---------------------&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In MSQL Server Management Studio they run just fine, but I believe there are restrictions on these multiple statements over ODBC, and that they need to be converted to stored procedures serverside?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can anybody confirm this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;J&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Feb 2014 11:31:59 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Multiple-statements-in-SQL-query/m-p/623100#M683627</guid>
      <dc:creator>johanfo2</dc:creator>
      <dc:date>2014-02-24T11:31:59Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple statements in SQL query</title>
      <link>https://community.qlik.com/t5/QlikView/Multiple-statements-in-SQL-query/m-p/623101#M683628</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Using server side stored procedures and calling them from the QlikView script including passing variables definitely works.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Feb 2014 12:13:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Multiple-statements-in-SQL-query/m-p/623101#M683628</guid>
      <dc:creator>simondachstr</dc:creator>
      <dc:date>2014-02-24T12:13:41Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple statements in SQL query</title>
      <link>https://community.qlik.com/t5/QlikView/Multiple-statements-in-SQL-query/m-p/623102#M683629</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;- you can use stored procedures&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- you can change your statement in TSQL e transform it in a sigle query&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- or split your TSQL script in that way in qlikview &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tmp:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;LOAD *;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;SQL &lt;/SPAN&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 10pt; line-height: 1.5em;"&gt;SELECT max(MyColumn) as MaxField from Holdings;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// set a qlikview variable using peek function&lt;/P&gt;&lt;P&gt;LET vMaxDate = peek('MaxField', 0, 'Tmp');&lt;/P&gt;&lt;P&gt;DROP TABLE Tmp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// use that variable to filter the select in sql server&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;LOAD *;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;SQL&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;select * from AnotherTable Where Column &amp;lt; '$(vMaxDate)';&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Feb 2014 12:28:10 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Multiple-statements-in-SQL-query/m-p/623102#M683629</guid>
      <dc:creator>maxgro</dc:creator>
      <dc:date>2014-02-24T12:28:10Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple statements in SQL query</title>
      <link>https://community.qlik.com/t5/QlikView/Multiple-statements-in-SQL-query/m-p/623103#M683630</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the problem is that QV will see the semi-colon (;) as ending the SQL statement. I have not tried this, but perhaps:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;declare @maxdate date&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;GO&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;select @maxdate =&amp;nbsp; max(MyColumn) from Holdings&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;select * from AnotherTable Where Column &amp;lt; @maxdate;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;will work? If not, you can package them in a stored proc and call them with &lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;BR /&gt;SQL EXEC ....&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;HTH&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;Jonathan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Feb 2014 12:31:15 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Multiple-statements-in-SQL-query/m-p/623103#M683630</guid>
      <dc:creator>jonathandienst</dc:creator>
      <dc:date>2014-02-24T12:31:15Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple statements in SQL query</title>
      <link>https://community.qlik.com/t5/QlikView/Multiple-statements-in-SQL-query/m-p/623104#M683631</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I tried to "GO" approach now,&amp;nbsp; didn't work. Thanks a lot for your answers.&amp;nbsp; I guess they confirmed my suspicions, and that is good.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;J&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Feb 2014 13:04:01 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Multiple-statements-in-SQL-query/m-p/623104#M683631</guid>
      <dc:creator>johanfo2</dc:creator>
      <dc:date>2014-02-24T13:04:01Z</dc:date>
    </item>
  </channel>
</rss>

