9 Replies Latest reply: Apr 4, 2017 5:49 PM by Vishwarath Nagaraju RSS

    Dynamically assign SQL Database based on date

    Jeb Pittard

      I have a reference table in SQL that automatically updates so that you can pick yesterday's snapshot - UNIXAKCCollection.dbo.KC_Named. 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.




      //Dataset selects Yesterday's snapshot




      SQL  Select PhysicalName as DBName

      From UNIXAKCCollection.dbo.KC_Named as N

      Inner Join UNIXAKCCollection.dbo.KC_Databases D on N.NameID = D.NameID

      WHERE N.DatabaseID =1

        and N.DatabaseTag =1;


      Let vdatabase = Peek('DBName','YesterDatabase'); //However vdatabase variable is null



      SQL select * from $(vdatabase).larmstr;