Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
RogerSteinberg
Post Patron
Post Patron

How to pass and INT parameter to stored procedure query in pbi

Hi,

 

I have the following query that executes a stored procedure in sql server. I would like to pass an INT parameter that I created in power query called CountryNumber

 

let
    Source = Sql.Database("server_name", "db_name", [Query="execute spTest ", CommandTimeout=#duration(0, 1, 0, 0)])
in
    Source

 

How can I do this. Please don't answer with a link to another page. I haven't found one that shows how to include INT

 

Ty

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@RogerSteinberg , It should be like

 

let
Source = Sql.Database("server_name", "db_name", [Query="execute spTest 1", CommandTimeout=#duration(0, 1, 0, 0)])
in
Source

 

//In case you want to give parameter

let
Source = Sql.Database("server_name", "db_name", [Query="execute spTest "& Number.FromText(vInput) , CommandTimeout=#duration(0, 1, 0, 0)])
in
Source

 

https://www.c-sharpcorner.com/article/execute-sql-server-stored-procedure-with-user-parameter-in-pow...

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@RogerSteinberg , It should be like

 

let
Source = Sql.Database("server_name", "db_name", [Query="execute spTest 1", CommandTimeout=#duration(0, 1, 0, 0)])
in
Source

 

//In case you want to give parameter

let
Source = Sql.Database("server_name", "db_name", [Query="execute spTest "& Number.FromText(vInput) , CommandTimeout=#duration(0, 1, 0, 0)])
in
Source

 

https://www.c-sharpcorner.com/article/execute-sql-server-stored-procedure-with-user-parameter-in-pow...

Greg_Deckler
Super User
Super User

@RogerSteinberg - So this doesn't work?

 

let
    Source = Sql.Database("server_name", "db_name", [Query="execute spTest CountryNumber", CommandTimeout=#duration(0, 1, 0, 0)])
in
    Source

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

no

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.