<?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 Translate qv into sql code in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Translate-qv-into-sql-code/m-p/174683#M43414</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Dear All,&lt;/P&gt;&lt;P&gt;I need to translate the below qv into sql code. The idea behind is that there is a number of databases each including a given Table that I need to source from. Because the number of dbs is high and dynamic, I use a for...next loop and a table with all dbs names (dbo_Configuration.dbo.Bases) to query them. Now, I need to translate it into sql using "while", and, got stuck. Could you please help preparing it?&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;I&gt;Bases:&lt;/I&gt; &lt;STRONG&gt;SELECT&lt;/STRONG&gt; Base_Name AS Base FROM dbo_Configuration.dbo.Bases&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;STRONG&gt;LET&lt;/STRONG&gt; NoOfBases = &lt;STRONG&gt;NoOfRows&lt;/STRONG&gt;('Bases');&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;STRONG&gt;FOR&lt;/STRONG&gt; &lt;STRONG&gt;i&lt;/STRONG&gt;=0 &lt;STRONG&gt;TO&lt;/STRONG&gt; $(NoOfBases)-1&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;STRONG&gt;LET&lt;/STRONG&gt; B = &lt;STRONG&gt;peek&lt;/STRONG&gt;('Base',$(i),'Bases');&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;STRONG&gt;LET&lt;/STRONG&gt; C = 'dbo_'&amp;amp; peek('Base',$(i),'Bases')&amp;amp; '.dbo.Table&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;STRONG&gt;SELECT&lt;/STRONG&gt; *&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;STRONG&gt;FROM&lt;/STRONG&gt; $(C);&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;STRONG&gt;NEXT&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P&gt;BR,&lt;/P&gt;&lt;P&gt;Przemek&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 06 Nov 2010 14:54:11 GMT</pubDate>
    <dc:creator />
    <dc:date>2010-11-06T14:54:11Z</dc:date>
    <item>
      <title>Translate qv into sql code</title>
      <link>https://community.qlik.com/t5/QlikView/Translate-qv-into-sql-code/m-p/174683#M43414</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Dear All,&lt;/P&gt;&lt;P&gt;I need to translate the below qv into sql code. The idea behind is that there is a number of databases each including a given Table that I need to source from. Because the number of dbs is high and dynamic, I use a for...next loop and a table with all dbs names (dbo_Configuration.dbo.Bases) to query them. Now, I need to translate it into sql using "while", and, got stuck. Could you please help preparing it?&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;I&gt;Bases:&lt;/I&gt; &lt;STRONG&gt;SELECT&lt;/STRONG&gt; Base_Name AS Base FROM dbo_Configuration.dbo.Bases&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;STRONG&gt;LET&lt;/STRONG&gt; NoOfBases = &lt;STRONG&gt;NoOfRows&lt;/STRONG&gt;('Bases');&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;STRONG&gt;FOR&lt;/STRONG&gt; &lt;STRONG&gt;i&lt;/STRONG&gt;=0 &lt;STRONG&gt;TO&lt;/STRONG&gt; $(NoOfBases)-1&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;STRONG&gt;LET&lt;/STRONG&gt; B = &lt;STRONG&gt;peek&lt;/STRONG&gt;('Base',$(i),'Bases');&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;STRONG&gt;LET&lt;/STRONG&gt; C = 'dbo_'&amp;amp; peek('Base',$(i),'Bases')&amp;amp; '.dbo.Table&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;STRONG&gt;SELECT&lt;/STRONG&gt; *&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;STRONG&gt;FROM&lt;/STRONG&gt; $(C);&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;STRONG&gt;NEXT&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P&gt;BR,&lt;/P&gt;&lt;P&gt;Przemek&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 06 Nov 2010 14:54:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Translate-qv-into-sql-code/m-p/174683#M43414</guid>
      <dc:creator />
      <dc:date>2010-11-06T14:54:11Z</dc:date>
    </item>
    <item>
      <title>Translate qv into sql code</title>
      <link>https://community.qlik.com/t5/QlikView/Translate-qv-into-sql-code/m-p/174684#M43415</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Think you should exchange the "$(i)" with "i" in your LET-statements, similarly in the FOR-statement you may simply refer to NoOfBases or replace straight with the formula.&lt;/P&gt;&lt;P&gt;HTH&lt;BR /&gt;Peter&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 07 Nov 2010 13:31:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Translate-qv-into-sql-code/m-p/174684#M43415</guid>
      <dc:creator>prieper</dc:creator>
      <dc:date>2010-11-07T13:31:25Z</dc:date>
    </item>
    <item>
      <title>Translate qv into sql code</title>
      <link>https://community.qlik.com/t5/QlikView/Translate-qv-into-sql-code/m-p/174685#M43416</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you, Peter. I replace FOR...NEXT loop with WHILE but the problem is with PEEK - as far as I know there's no such function in SQL except for TOP but this only lets choose the very top row(s) where as PEEK lets you choose any row.&lt;/P&gt;&lt;P&gt;Using TOP 1 you may create a script but you will have to delete the row after reading which I don't want to do and look for a better solution.&lt;/P&gt;&lt;P&gt;BR, Przemek&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 07 Nov 2010 16:58:38 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Translate-qv-into-sql-code/m-p/174685#M43416</guid>
      <dc:creator />
      <dc:date>2010-11-07T16:58:38Z</dc:date>
    </item>
  </channel>
</rss>

