Forum Discussion
Parameterized SQL Query with query folding
- Anonymous9 years ago
Hi schdef,
You can tansfrom your data to text, then use it into sql query.
Sample: Convert region records to text.
let Source=data, Region = "'"&Text.Combine(List.Distinct(Source[Region]),"','")&"'" in RegionInsert into sql query:
let Source = Sql.Database("xxxxx", "xxxxx", [Query="SELECT * FROM Sales WHERE Region In ("&Region&")"]) in SourceRegards,
Xiaoxin Sheng
Hi schdef,
You can tansfrom your data to text, then use it into sql query.
Sample: Convert region records to text.
let
Source=data,
Region = "'"&Text.Combine(List.Distinct(Source[Region]),"','")&"'"
in
Region
Insert into sql query:
let
Source = Sql.Database("xxxxx", "xxxxx", [Query="SELECT * FROM Sales WHERE Region In ("&Region&")"])
in
Source
Regards,
Xiaoxin Sheng
I am working in Excel Power Pivot, my parameter list is generated from a table in the worksheet. The list generates well, and it displays correctly in the Query that is supposed to go out to SQL. Everything looks good, except, I am running into a Formula.Firewall error message complaining that my step 'Source' references other queries and I need to rebuild it.
For months, I have been trying to figure out a way to fold dynamic parameters back to SQL. This is the closest I have gotten. I can see how this should work. I can't get around the error message though.
Is there something I need to be aware of when connecting to the database? Has something changed in the software that prevents this from folding back as intended? Are there better ways today to accomplish this task?
- Anonymous6 years agoNot applicable
Even i have same error refelecting ? I couldnt find solution for that . Is there anyother way to do it ?
- Anonymous6 years agoNot applicable