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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
prateekraina
Memorable Member
Memorable Member

Calling SQL stored procedure with Direct Query

Hi Guys,

 

I was pretty stunned to know today that we cannot simply call a stored procedure in direct query mode as it gives systax error after closing Query Editor.

 

Can anyone provide any workarounds as i cannot switch to model based connection.

 

Prateek Raina

7 REPLIES 7
a4peterson
Frequent Visitor

At our end, we have full ability to setup new functions, so the easiest is to just configure the SP as a function. OpenRowset/Openquery will work but is messy.  

a4peterson
Frequent Visitor

You can also convert the stored procedures to table based functions. Then use a select * from <function_name> in Power BI.  

nickchobotar
Skilled Sharer
Skilled Sharer

Hello @prateekraina

 

 

Same here. I am able to load the data into PQ but once I close it I get back incorrect syntax error


image.png
image.png

 

image.png

Hi , @nickchobotar@prateekraina

I have the same problem did you find suitable solution?.

 

 

BR,
Noa.

@Noak

 

Nope. Actually, there should not be a solution or a workaround to this. It should just work..... 

 

This issue is on the lis of PBI ideas (only 4 votes of today). Please vote!

 

https://ideas.powerbi.com/forums/265200-power-bi-ideas/suggestions/33504791-direct-query

 

 

 

 

 

 

 

 

N -

Hi @nickchobotar,

I voted .

 

I did my research and found a solution use the following query (replace server name and parameters you would like to use):

 

select *
from
openrowset('SQLOLEDB','SERVER=SERVERNAME;Trusted_Connection=yes;',' set fmtonly off;exec DATABASE..SPNAME @StartDate=''2018-01-01'' ,@EndDate=''2018-01-04'' ')

 

(you need to alow openrowset functionality at your sqlserver database)

BR,
Noa.
Anonymous
Not applicable

I know it's been a while but as you know they haven't fixed the problem.
Questions, I tried this code with no success. How did you set it up in your PBI file?

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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