Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin 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.
I have a SP in Azure SQL Database, the SP runs fine in azure and into the transform (power query) window, but it's unable to load into the data model. It returns back Microsoft SQL: Incorrect syntax near the keyword 'exec'.
Incorrect syntax near ')'.
Solved! Go to Solution.
Hi @srduval
Do you import data or use direct-query?
Check the document below to see if you do the right thing.
Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
I'm getting this error on calling MSSQL Stored Procedures by Power Query, when:
Both the scenarios I'm showing work on the Power Query Editor.
The error shows when loading the data onto the PowerBI file.
This seems to be a bug on the interface that calls the MSSQL code. From my point of view it should not require the work around of calling the SP by a function, as it was suggested.
I've been able to call the SP without the need for the "fuction", (this code works on Import Mode), and load data into PowerBI.
Sql.Database(#"Server", #"DB", [Query="EXEC [Stored_Procedure] '" & Date.ToText( RangeStart_Date , [Format="yyyy-MM-dd"] ) & "', '" & Date.ToText( RangeEnd_Date, [Format="yyyy-MM-dd"] ) & "'"])
However when I call an extra date transformation, from DateTime -> Date, the code throughs the error: Microsoft SQL: Incorrect syntax near the keyword 'exec'. Incorrect syntax near ')'
Sql.Database(#"Server", #"DB", [Query="EXEC [Stored_Procedure] '" & Date.ToText( DateTime.Date( RangeStart ) , [Format="yyyy-MM-dd"] ) & "', '" & Date.ToText( DateTime.Date( RangeEnd_Date ), [Format="yyyy-MM-dd"] ) & "'"])
What's happening here?
same issue but i need in direct query is it any solution.
Hi @srduval
Do you import data or use direct-query?
Check the document below to see if you do the right thing.
Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
my mistake I must have been using direct query on accident. Works fine today on import
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
9 | |
6 | |
6 | |
6 | |
6 |