Forum Discussion
Error loading data
Is that the answer?
https://community.powerbi.com/t5/Desktop/Why-is-DECLARE-not-supported-Error/td-p/40983
So, still a bug even after converting into a SP???
Hi Markzolotoy
What kind of connection mode did you try to connect to SQL, import or Direct Query?
I found a post with the smiliar problem like yours, he solved his problem by change connection mode from Direct Query to import.
Here is the post: Microsoft SQL: Incorrect syntax near the keyword 'exec'. Incorrect syntax near ')'.
From this blog:Incorrect syntax in Power BI - but query works fine in SSMS? I found that Power BI Desktop has issues on parsing Queries in Direct Query mode. It always resolves the front end input SQL statement as a derived table so that statements like DECLARE, CTE will cause syntax error.
Please try to connect to SQL by import with this code.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.