<?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: Variable in SQL in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Variable-in-SQL/m-p/869412#M658380</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Much easier if you move all your dynamic logic into a procedure&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #000000;"&gt;set vtable = 'TAB01'&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #000000;"&gt;&lt;TABLE&gt;:&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #000000;"&gt;SQL &lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: inherit;"&gt;Exec&amp;nbsp; '$(vtable)'&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #000000;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: inherit;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #000000;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: inherit;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #000000;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: inherit;"&gt;Useful reading:&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #000000;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: inherit;"&gt;&lt;A href="https://technet.microsoft.com/en-us/library/aa225239%28v=sql.80%29.aspx" title="https://technet.microsoft.com/en-us/library/aa225239%28v=sql.80%29.aspx"&gt;https://technet.microsoft.com/en-us/library/aa225239%28v=sql.80%29.aspx&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #000000;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: inherit;"&gt;&lt;A href="http://docs.oracle.com/cd/B19306_01/appdev.102/b14261/executeimmediate_statement.htm" title="http://docs.oracle.com/cd/B19306_01/appdev.102/b14261/executeimmediate_statement.htm"&gt;PL/SQL Language Elements&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TABLE&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 15 May 2015 13:48:26 GMT</pubDate>
    <dc:creator>Clever_Anjos</dc:creator>
    <dc:date>2015-05-15T13:48:26Z</dc:date>
    <item>
      <title>Variable in SQL</title>
      <link>https://community.qlik.com/t5/QlikView/Variable-in-SQL/m-p/869405#M658373</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;I´d like to create simething like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;set vtable = 'TAB01'&lt;/P&gt;&lt;P&gt;&lt;TABLE&gt;:&lt;P&gt;&lt;/P&gt;&lt;P&gt;SQL&lt;/P&gt;&lt;P&gt;declare @xtab varchar(500)&lt;/P&gt;&lt;P&gt;declare @sql varchar(max)&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;set @xtab= $(vtable)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Set @sql = 'SELECT * from '+@xtab&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Exec(@sql);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;How can I do this?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Thanks a lot&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TABLE&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 May 2015 11:22:00 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Variable-in-SQL/m-p/869405#M658373</guid>
      <dc:creator />
      <dc:date>2015-05-15T11:22:00Z</dc:date>
    </item>
    <item>
      <title>Re: Variable in SQL</title>
      <link>https://community.qlik.com/t5/QlikView/Variable-in-SQL/m-p/869406#M658374</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;SET vtable = TAB01;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Table:&lt;/P&gt;&lt;P&gt;SQL Select * From $(vtable);&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 May 2015 11:35:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Variable-in-SQL/m-p/869406#M658374</guid>
      <dc:creator>Gysbert_Wassenaar</dc:creator>
      <dc:date>2015-05-15T11:35:56Z</dc:date>
    </item>
    <item>
      <title>Re: Variable in SQL</title>
      <link>https://community.qlik.com/t5/QlikView/Variable-in-SQL/m-p/869407#M658375</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;u have to use ur variable in sql with $ symbol.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 May 2015 11:45:31 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Variable-in-SQL/m-p/869407#M658375</guid>
      <dc:creator>buzzy996</dc:creator>
      <dc:date>2015-05-15T11:45:31Z</dc:date>
    </item>
    <item>
      <title>Re: Variable in SQL</title>
      <link>https://community.qlik.com/t5/QlikView/Variable-in-SQL/m-p/869408#M658376</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;So, what I need is to create a variable because my sql will be dynamic! No just the table I´ll change... I used this example just so simplify! &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The real situation is that I need to put many 'unions' in my sql! &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 May 2015 11:45:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Variable-in-SQL/m-p/869408#M658376</guid>
      <dc:creator />
      <dc:date>2015-05-15T11:45:51Z</dc:date>
    </item>
    <item>
      <title>Re: Variable in SQL</title>
      <link>https://community.qlik.com/t5/QlikView/Variable-in-SQL/m-p/869409#M658377</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Build up the sql statement in a variable then execute it:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SET vTable = MyTable;&lt;/P&gt;&lt;P&gt;LET vWhere = 'MyField &amp;gt; 0'&lt;/P&gt;&lt;P&gt;SET vSQL = SELECT * FROM $(vTable) $(vWhere);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Table:&lt;/P&gt;&lt;P&gt;SQL $(vSQL);&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 May 2015 11:50:45 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Variable-in-SQL/m-p/869409#M658377</guid>
      <dc:creator>Gysbert_Wassenaar</dc:creator>
      <dc:date>2015-05-15T11:50:45Z</dc:date>
    </item>
    <item>
      <title>Re: Variable in SQL</title>
      <link>https://community.qlik.com/t5/QlikView/Variable-in-SQL/m-p/869410#M658378</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;However "@SQL" is a variable in SQL, not in Qlikview!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 May 2015 11:52:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Variable-in-SQL/m-p/869410#M658378</guid>
      <dc:creator />
      <dc:date>2015-05-15T11:52:56Z</dc:date>
    </item>
    <item>
      <title>Re: Variable in SQL</title>
      <link>https://community.qlik.com/t5/QlikView/Variable-in-SQL/m-p/869411#M658379</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;i mean in qlikview sql script u have to use $ symbol..if u want to use the variable.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 May 2015 11:56:00 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Variable-in-SQL/m-p/869411#M658379</guid>
      <dc:creator>buzzy996</dc:creator>
      <dc:date>2015-05-15T11:56:00Z</dc:date>
    </item>
    <item>
      <title>Re: Variable in SQL</title>
      <link>https://community.qlik.com/t5/QlikView/Variable-in-SQL/m-p/869412#M658380</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Much easier if you move all your dynamic logic into a procedure&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #000000;"&gt;set vtable = 'TAB01'&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #000000;"&gt;&lt;TABLE&gt;:&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #000000;"&gt;SQL &lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: inherit;"&gt;Exec&amp;nbsp; '$(vtable)'&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #000000;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: inherit;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #000000;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: inherit;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #000000;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: inherit;"&gt;Useful reading:&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #000000;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: inherit;"&gt;&lt;A href="https://technet.microsoft.com/en-us/library/aa225239%28v=sql.80%29.aspx" title="https://technet.microsoft.com/en-us/library/aa225239%28v=sql.80%29.aspx"&gt;https://technet.microsoft.com/en-us/library/aa225239%28v=sql.80%29.aspx&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #000000;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: inherit;"&gt;&lt;A href="http://docs.oracle.com/cd/B19306_01/appdev.102/b14261/executeimmediate_statement.htm" title="http://docs.oracle.com/cd/B19306_01/appdev.102/b14261/executeimmediate_statement.htm"&gt;PL/SQL Language Elements&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TABLE&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 May 2015 13:48:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Variable-in-SQL/m-p/869412#M658380</guid>
      <dc:creator>Clever_Anjos</dc:creator>
      <dc:date>2015-05-15T13:48:26Z</dc:date>
    </item>
    <item>
      <title>Re: Variable in SQL</title>
      <link>https://community.qlik.com/t5/QlikView/Variable-in-SQL/m-p/869413#M658381</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I got this way:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;set xpto = '';&lt;/P&gt;&lt;P&gt;let counter = 1;&lt;/P&gt;&lt;P&gt;let xempa = '010060';&lt;/P&gt;&lt;P&gt;do while counter &amp;lt; 3&lt;/P&gt;&lt;P&gt;&amp;nbsp; let xemp = mid($(xempa),1,3);&lt;/P&gt;&lt;P&gt;&amp;nbsp; if $(counter) &amp;gt; 1 then&lt;/P&gt;&lt;P&gt;&amp;nbsp; set xpto = $(xpto) union all&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set xpto = $(xpto) Select top 10 $(counter) as emp, E1_NUM from SE1$(xemp);&lt;/P&gt;&lt;P&gt;&amp;nbsp; Else&lt;/P&gt;&lt;P&gt;&amp;nbsp; set xpto =&amp;nbsp; Select top 10 $(counter) as emp, E1_NUM from SE1$(xemp);&lt;/P&gt;&lt;P&gt;&amp;nbsp; Endif&lt;/P&gt;&lt;P&gt;&amp;nbsp; let counter = counter + 1; &lt;/P&gt;&lt;P&gt;&amp;nbsp; let xempa = mid($(xempa),4,len($(xempa))-3);&lt;/P&gt;&lt;P&gt;loop&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;teste:&lt;/P&gt;&lt;P&gt;SQL &lt;/P&gt;&lt;P&gt;$(xpto);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot everybody!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 May 2015 13:52:50 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Variable-in-SQL/m-p/869413#M658381</guid>
      <dc:creator />
      <dc:date>2015-05-15T13:52:50Z</dc:date>
    </item>
  </channel>
</rss>

