Forum Discussion
michaeljc70
10 years agoAdvocate II
Query with CTE gives error
I used SQL Server and a query that uses a CTE. It gives me an error "Incorrent syntax near the Keyword 'WITH'. ......."if this is a common table expression......previous statement must be terminated...
jimjao
8 years agoNew Member
Hi all,
Using Power BI Desktop (October 2017), I was able to use CTE query with an OLE DB connection to the SQL Server.
So, Power BI does support CTE.
Jim Jao
MasterCMU
6 years agoNew Member
Yes, this is still correct in Power BI Desktop November 2019 - confirmed it works ONLY through a OLE DB connection to SQL rather than through the SQL connection in Power BI. I came across the issue with CTE at the final "Apply" stage of Power Query with a Direct Connection and while the preview was working, the Apply and Close would fail with the same message as OP's. Using JimJao's fix with Ole DB I got it to Apply and Update. So it seems to be a bug in the SQL connector.