简体   繁体   中英

Stored Procedure usage in Azure SQL Database with Direct Query Mode

I have created stored procedures in Azure SQL Database and trying to use them power BI report with Direct Query mode. But getting the error like

"Microsoft SQL: Incorrect syntax near the keyword 'EXEC'. Incorrect syntax near ')'.

Another question is

how to set the connection string as global so that I can use the same connection string in multiple reports?

Please help me with the solution

I assume you are using Power BI Desktop. When it constructs a DirectQuery SQL query it does this:

Select column1
From (
 YourQuery
) as t1

So it fails because you can't put EXEC in the from clause of a SELECT query.

Your options:

  1. Stop using DirectQuery. Using a stored proc in cached mode will work because it just runs your query without any changes during refresh. Why would this not work for you?

  2. Take the query out of the stored proc and put it inline into PBI Desktop. Then it should work with DirectQuery as long as it is a single statement simple select.

Regarding reusing the connection (and I assume you also mean reusing the model with calcs, relationships, etc) in another report. Turn on this new preview feature under PBI Desktop options and you can connect to a published dataset (the model/data/connection) in Power BI Service.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM