Excel 2013 power query - SQL query with a dynamic parameter -
however have looked web cant find simple(!) example show how use , have sql query use in dynamic parameter value.
what i'm looking end user able change value in column in spreadsheet (parametertable?) , refresh data using new value parameter.
perhaps example describes best i'm after.
i have table in excel have 2 columns, named parametername , parametervalue. these have values parm1 , 1 (sorry appears cant post image here)
the query this, if 1=1 retrieve current date (this oracle should same other databases)
select sysdate dual 1 = 1;
how should change above use paramatername , parametervalue, i.e. rightmost "1" changed dynamically value. if value else "1" no results returned.
thanks in advance
i have way pass parameter power query. make sure works.
step 1: create table named "infodesk" in excel, or can name wish. table "infodesk" contains column "script" place sql script in column.
step 2: create blank power query, click on advance editor, , input following code
let source = sql.database("192.168.23.81", "dbo.name", [query= excel.currentworkbook(){[name="infodesk"]}[content][script]{0}]) in source
and then, run query. code [script]{0}] data 1st row, can place multiple script in column, change {0} >> {1} or {2} ... data other rows.
in order change parameter in sql script, may use excel function =concatenate() combine multiple excel cells completed sql.
Comments
Post a Comment