Forum Discussion
Very specific question on Using OPENROWSET in PBI with a multivalued parameter
- 1 year ago
Not clear where you are stuck? Do you have problems converting the list into a string?
Sql.Database("SERVERNAME", "DATABASE" ,
[Query="SELECT * FROM OPENROWSET #(lf)('SQLNCLI','server=SERVER ;
Why are you connecting to the server twice? Are you doing server hopping with linked servers?
In Power Query use Value.Is() to probe the type of the object (list or scalar) and consider using try ... otherwise ... to harden your code.
Hi, sorry for the delayed reply.
Thanks for your response (and yes, we need to use linked servers, that is another story, though let me clarify:
See the code below. This was calling a proc called "RunMyProc " and passing in a single string key parameter. That worked fine.
I changed the proc to receive a long CSV string for multiple keys - inside the SQL proc, I'd convert the long CSV to a table variable and join on it.
However, I can't find the "magic syntax" that will allow me to pass @KeyValue as a comma-separated list of strings.
@Keyvalue is a parameter coming from a slicer tied to a parameter that allows a mult-select.
So I might have a list of keys that the user selects....out of 1,000, it might be
101
104
105
107
I want to pass that list of four keys (or 8 keys, or whatever) to the proc, using DirectQuery below.
And I'm stuck on the syntax - Maybe because I came from SSRS, I'm used to doing this with SSRS and T-SQL and strings, and I'm stuck.
Again, here is the syntax I'm trying to modify, and I'm stuck. Thanks
= Sql.Database("SERVERNAME", "DATABASE" ,
[Query="SELECT * FROM OPENROWSET #(lf)('SQLNCLI','server=SERVER ;uid=ID;pwd=PW',
'EXEC DATABASE.DBO.RunMyProc """ & @KeyValue & """')"]
- lbendlin1 year ago
Super User
Not clear where you are stuck? Do you have problems converting the list into a string?