Incorrect syntax near the keyword 'WITH' when try to "Explore results"

Database
MS SQL Server

Working
"With" statement is working perfectly when just using and displaying SQL questions on dashboards for example.

Not working
"Exploring results" on a SQL question with a "With" statement results in the following error:
Incorrect syntax near the keyword 'WITH'

Does anybody know why this is happening and|or know how to fix it?

Hi @v4Jt
It's a limitation of SQL Server. The only fix is to not use CTEs for nested queries:
https://github.com/metabase/metabase/issues/18685 - upvote by clicking :+1: on the first post

1 Like