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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
TahmidBari
Helper I
Helper I

SQL stored procedures in DirectQuery mode

Hi there,

I have read the comments on the relevant PBI forums about calling SQL stored procedures in DirectQuery mode, but it's not working for me. Could you please assist me validate the following syntax with an example for connecting a stored procedure in DirectQuery mode? Many Thanks.

select *
from
openrowset('SQLOLEDB','SERVER=SERVERNAME;Trusted_Connection=yes;',' set fmtonly off;

exec DATABASE..SPNAME

@StartDate=''2023-01-01'' ,

@EndDate=''2023-01-04'' ')

https://learn.microsoft.com/en-us/sql/t-sql/functions/openrowset-transact-sql?view=sql-server-2017

2 REPLIES 2
TahmidBari
Helper I
Helper I

Hi @amitchandak, Thanks for sharing the information. I understand that we won't be able to pass parameters to stored procedures, and we can't execute them in direct query mode. We can however, create table valued functions which give us the ability to use table variables and perform other functions that are more complex in nature in 'DirectQuery' mode.

When I try to connect a stored procedure in SELECT from OPENROWSET from 'DirectQuery,' mode, I get the following error message. Thanks.

TahmidBari_0-1672959881084.png

amitchandak
Super User
Super User

@TahmidBari , Both old tickets suggest openrowset option

https://community.powerbi.com/t5/Desktop/Can-i-call-Stored-Procedure-with-Direct-Query/m-p/267141

https://community.powerbi.com/t5/Power-Query/Stored-Procedures-in-Direct-Query-mode/td-p/2640876

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

November Carousel

Fabric Community Update - November 2024

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

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.