<?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: Dynamically assign SQL Database based on date in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Dynamically-assign-SQL-Database-based-on-date/m-p/1340847#M617668</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can you tell what variable is holding?&lt;/P&gt;&lt;P&gt;May be try this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;EM style="font-weight: inherit; font-family: inherit;"&gt;SQL select * from '$(vdatabase)'.larmstr;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 04 Apr 2017 20:51:15 GMT</pubDate>
    <dc:creator>vishsaggi</dc:creator>
    <dc:date>2017-04-04T20:51:15Z</dc:date>
    <item>
      <title>Dynamically assign SQL Database based on date</title>
      <link>https://community.qlik.com/t5/QlikView/Dynamically-assign-SQL-Database-based-on-date/m-p/1340842#M617663</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a reference table in SQL that automatically updates so that you can pick yesterday's snapshot - &lt;STRONG&gt;&lt;EM&gt; &lt;/EM&gt;&lt;/STRONG&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;STRONG&gt;&lt;EM&gt;UNIXAKCCollection.dbo.KC_Named&lt;/EM&gt;&lt;/STRONG&gt;&lt;EM&gt;. &lt;/EM&gt;However, when I run the code below and try to use a variable and the Peek command the field results are null. Any help would be greatly appreciated.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;Thank&lt;/SPAN&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;s&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;JP&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM style="color: #339966;"&gt;//Dataset selects Yesterday's snapshot&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;YesterDatabase:&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;SQL&amp;nbsp; Select PhysicalName as DBName&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;From UNIXAKCCollection.dbo.KC_Named as N&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;Inner Join UNIXAKCCollection.dbo.KC_Databases D on N.NameID = D.NameID&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;WHERE N.DatabaseID =1&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;&amp;nbsp; and N.DatabaseTag =1;&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;Let vdatabase = Peek('DBName','YesterDatabase'); &lt;SPAN style="color: #339966;"&gt;//However vdatabase variable is null&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;SQL select * from $(vdatabase).larmstr;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Apr 2017 17:31:00 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Dynamically-assign-SQL-Database-based-on-date/m-p/1340842#M617663</guid>
      <dc:creator />
      <dc:date>2017-04-04T17:31:00Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically assign SQL Database based on date</title>
      <link>https://community.qlik.com/t5/QlikView/Dynamically-assign-SQL-Database-based-on-date/m-p/1340843#M617664</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try this?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;Let vdatabase = Peek('DBName',&lt;/STRONG&gt; &lt;STRONG&gt;&lt;SPAN style="color: #ff0000;"&gt;-1&lt;/SPAN&gt;,&lt;/STRONG&gt;&lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;'YesterDatabase');&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Apr 2017 18:42:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Dynamically-assign-SQL-Database-based-on-date/m-p/1340843#M617664</guid>
      <dc:creator>vishsaggi</dc:creator>
      <dc:date>2017-04-04T18:42:08Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically assign SQL Database based on date</title>
      <link>https://community.qlik.com/t5/QlikView/Dynamically-assign-SQL-Database-based-on-date/m-p/1340844#M617665</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That worked well. Thanks. However, I have a new error when I try the next select clause:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;ODBC read failed&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;SQL select *&amp;nbsp; from UNIXASnapshot20170403.dbo.larmstr&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note that I added in the dbo in the table name.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Apr 2017 19:04:13 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Dynamically-assign-SQL-Database-based-on-date/m-p/1340844#M617665</guid>
      <dc:creator />
      <dc:date>2017-04-04T19:04:13Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically assign SQL Database based on date</title>
      <link>https://community.qlik.com/t5/QlikView/Dynamically-assign-SQL-Database-based-on-date/m-p/1340845#M617666</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Are you using variable in that next select script?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Apr 2017 19:29:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Dynamically-assign-SQL-Database-based-on-date/m-p/1340845#M617666</guid>
      <dc:creator>vishsaggi</dc:creator>
      <dc:date>2017-04-04T19:29:02Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically assign SQL Database based on date</title>
      <link>https://community.qlik.com/t5/QlikView/Dynamically-assign-SQL-Database-based-on-date/m-p/1340846#M617667</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes and when I copy the text of the error message and run it it SSMS it works fine.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Apr 2017 19:45:44 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Dynamically-assign-SQL-Database-based-on-date/m-p/1340846#M617667</guid>
      <dc:creator />
      <dc:date>2017-04-04T19:45:44Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically assign SQL Database based on date</title>
      <link>https://community.qlik.com/t5/QlikView/Dynamically-assign-SQL-Database-based-on-date/m-p/1340847#M617668</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can you tell what variable is holding?&lt;/P&gt;&lt;P&gt;May be try this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;EM style="font-weight: inherit; font-family: inherit;"&gt;SQL select * from '$(vdatabase)'.larmstr;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Apr 2017 20:51:15 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Dynamically-assign-SQL-Database-based-on-date/m-p/1340847#M617668</guid>
      <dc:creator>vishsaggi</dc:creator>
      <dc:date>2017-04-04T20:51:15Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically assign SQL Database based on date</title>
      <link>https://community.qlik.com/t5/QlikView/Dynamically-assign-SQL-Database-based-on-date/m-p/1340848#M617669</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, Vishwarath. That worked great. Thanks for the additional input. I realized that I had omitted a change in my code which I have corrected and now all parts of the script work.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Apr 2017 21:11:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Dynamically-assign-SQL-Database-based-on-date/m-p/1340848#M617669</guid>
      <dc:creator />
      <dc:date>2017-04-04T21:11:08Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically assign SQL Database based on date</title>
      <link>https://community.qlik.com/t5/QlikView/Dynamically-assign-SQL-Database-based-on-date/m-p/1340849#M617670</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So which one worked? &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Apr 2017 21:19:17 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Dynamically-assign-SQL-Database-based-on-date/m-p/1340849#M617670</guid>
      <dc:creator>vishsaggi</dc:creator>
      <dc:date>2017-04-04T21:19:17Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically assign SQL Database based on date</title>
      <link>https://community.qlik.com/t5/QlikView/Dynamically-assign-SQL-Database-based-on-date/m-p/1340850#M617671</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This syntax worked to assign the variable&lt;STRONG style="font-style: inherit; font-family: inherit;"&gt; &lt;/STRONG&gt;&lt;EM style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;Let vdatabase = Peek('DBName',&lt;/STRONG&gt; &lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: inherit; color: #ff0000;"&gt;-1&lt;/SPAN&gt;,&lt;/STRONG&gt;&lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;'YesterDatabase');&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;And this syntax worked for the query:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;SQL select * from $(vdatabase).dbo.larmstr;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Apr 2017 21:26:44 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Dynamically-assign-SQL-Database-based-on-date/m-p/1340850#M617671</guid>
      <dc:creator />
      <dc:date>2017-04-04T21:26:44Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically assign SQL Database based on date</title>
      <link>https://community.qlik.com/t5/QlikView/Dynamically-assign-SQL-Database-based-on-date/m-p/1340851#M617672</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Glad it worked. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Apr 2017 21:49:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Dynamically-assign-SQL-Database-based-on-date/m-p/1340851#M617672</guid>
      <dc:creator>vishsaggi</dc:creator>
      <dc:date>2017-04-04T21:49:35Z</dc:date>
    </item>
  </channel>
</rss>

