<?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: Auto load tables from MS SQL Database in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Auto-load-tables-from-MS-SQL-Database/m-p/12208#M1978</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Tim is right. The first extraction may work, as you are referring in your peek() function calls to the (default) table that was loaded last. But as soon as there is another resident table (the first one extracted from SQL Server), your peek() function calls will use a different default table that has no [Table Name] column and the calls will return NULL...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 29 Jan 2018 13:37:51 GMT</pubDate>
    <dc:creator>Peter_Cammaert</dc:creator>
    <dc:date>2018-01-29T13:37:51Z</dc:date>
    <item>
      <title>Auto load tables from MS SQL Database</title>
      <link>https://community.qlik.com/t5/QlikView/Auto-load-tables-from-MS-SQL-Database/m-p/12204#M1974</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello community,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm trying to load data from a database using an Excel file in wich I define the tables and fields names. Then I use a loop to load data into my qvw app.&lt;/P&gt;&lt;P&gt;I get a result for the first table but I get an error when the loop moove te the second table.&lt;/P&gt;&lt;P&gt;Here's the error&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="191705" alt="error.png" class="jive-image image-1" src="https://community.qlik.com/legacyfs/online/191705_error.png" style="height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And here's the script :&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_15172320004644021" jivemacro_uid="_15172320004644021"&gt;
&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;//Récupération de la liste des tables à charger à partir de la base&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;tmp_TablesNames:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;LOAD &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt; Distinct&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt; [Table Name]&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;FROM&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt; [$(p_Path_Package)\Data\QV_External_Table_Parameters.xlsx]&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt; (ooxml, embedded labels, table is TABLES);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;//Calcul du numbre de tables à parcourir&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;LET v_TablesNumber = NoOfRows('tmp_TablesNames');&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;//Boucle de chargement des tables&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;FOR i=0 TO $(v_TablesNumber)-1&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt; LET v_CurrentTableName = SubField(Peek('Table Name',$(i)),'.',-1);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt; LET v_CurrentTableSchema = Peek('Table Name',$(i));&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt; TRACE v_CurrentTableName = $(v_CurrentTableName);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt; $(v_CurrentTableName):&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt; LOAD&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt; *;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt; SQL&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt; Select&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt; *&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt; From&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt; $(v_CurrentTableSchema)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt; where 1=1;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;NEXT i&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;//Suppression de la table temporaire tmp_TablesNames&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;DROP Table tmp_TablesNames;&lt;/SPAN&gt;&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Jan 2018 13:18:37 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Auto-load-tables-from-MS-SQL-Database/m-p/12204#M1974</guid>
      <dc:creator>slaheddinekeyru</dc:creator>
      <dc:date>2018-01-29T13:18:37Z</dc:date>
    </item>
    <item>
      <title>Re: Auto load tables from MS SQL Database</title>
      <link>https://community.qlik.com/t5/QlikView/Auto-load-tables-from-MS-SQL-Database/m-p/12205#M1975</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;check your peek function calls. it should look like that:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Peek(field_name[, row_no[, table_name ] ] )&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;give that a try:&lt;/P&gt;&lt;P&gt;Peek('Table Name',$(i), 'tmp_TablesNames');&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Jan 2018 13:24:22 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Auto-load-tables-from-MS-SQL-Database/m-p/12205#M1975</guid>
      <dc:creator>zhadrakas</dc:creator>
      <dc:date>2018-01-29T13:24:22Z</dc:date>
    </item>
    <item>
      <title>Re: Auto load tables from MS SQL Database</title>
      <link>https://community.qlik.com/t5/QlikView/Auto-load-tables-from-MS-SQL-Database/m-p/12206#M1976</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Check the output of the TRACE statement (immediately before the error occurs). Does variable v_CurrentTableName contain a correct value? Because the $-sign expansion doesn't find one.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Jan 2018 13:29:29 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Auto-load-tables-from-MS-SQL-Database/m-p/12206#M1976</guid>
      <dc:creator>Peter_Cammaert</dc:creator>
      <dc:date>2018-01-29T13:29:29Z</dc:date>
    </item>
    <item>
      <title>Re: Auto load tables from MS SQL Database</title>
      <link>https://community.qlik.com/t5/QlikView/Auto-load-tables-from-MS-SQL-Database/m-p/12207#M1977</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;you can also try to Change this part&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;$(v_CurrentTableSchema) &lt;/P&gt;&lt;P&gt;where 1=1; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #ff0000;"&gt;'&lt;/STRONG&gt;&lt;STRONG&gt;&lt;SPAN style="color: #ff0000;"&gt;$(v_CurrentTableSchema)&lt;/SPAN&gt;&lt;STRONG style="color: #ff0000;"&gt;'&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;where 1=1; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Jan 2018 13:29:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Auto-load-tables-from-MS-SQL-Database/m-p/12207#M1977</guid>
      <dc:creator>zhadrakas</dc:creator>
      <dc:date>2018-01-29T13:29:51Z</dc:date>
    </item>
    <item>
      <title>Re: Auto load tables from MS SQL Database</title>
      <link>https://community.qlik.com/t5/QlikView/Auto-load-tables-from-MS-SQL-Database/m-p/12208#M1978</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Tim is right. The first extraction may work, as you are referring in your peek() function calls to the (default) table that was loaded last. But as soon as there is another resident table (the first one extracted from SQL Server), your peek() function calls will use a different default table that has no [Table Name] column and the calls will return NULL...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Jan 2018 13:37:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Auto-load-tables-from-MS-SQL-Database/m-p/12208#M1978</guid>
      <dc:creator>Peter_Cammaert</dc:creator>
      <dc:date>2018-01-29T13:37:51Z</dc:date>
    </item>
  </channel>
</rss>

