cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Arnoh Regular Visitor
Regular Visitor

passing parameter to sql query

Hi,

I would like to pass a parameter directly to the sql query. Or is this possible or only in M?

I prefer for further editing the native sql statement.

 

Thanx for any suggestions!

 

Knipsel.PNG

3 REPLIES 3
Community Support Team
Community Support Team

Re: passing parameter to sql query

Hi Arnoh,

As I know, you could achieve this by  M query.

You could try to write hard code in query like below “select *  from test where name=’a’”, then create a parameter

170.png

Then apply this parameter to query , you need to edit query like below

let

    Source = Sql.Database("servername", "newsql", [Query="select *  from test#(lf)where name ='"&namep&"'"])

in

    Source

171.png

The you could change value in parameter and run the query. You could refer to Pass parameter to SQL Queries statement using Power BI for details

Best Regards,

Zoe Zhi

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Arnoh Regular Visitor
Regular Visitor

Re: passing parameter to sql query

Hi I understand. But is it possible to use in in the native query? 

Community Support Team
Community Support Team

Re: passing parameter to sql query

Hi Arnoh,

As I know, if you use this in native query, I think  it("&namep&") might not be recognized by SQL. 

Best Regards,
Zoe Zhi

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Ask Amir Anything

Exclusive LIVE Community Event No. 2 – Ask Amir Anything

Next in our Triple A series: Ask Amir Netz questions about the latest updates, features and future.

October 2019 Community Highlights

October 2019 Community Highlights

October was a busy month in the community. Read the recap article to learn about some of the events and content.

New Solution Badges

New Solution Badges

Two waves of brand new solution badges are coming! Read the article for more information on our new community badges.

Analytics in Azure virtual event

Analytics in Azure virtual event

Experience a limitless analytics service built to ingest, prep, manage, and serve data for immediate use in Power BI.

Users Online
Currently online: 390 members 3,440 guests
Please welcome our newest community members: