Complex Dynamic SQL Syntax Issue in HelicalInsight Metadata View

Hello Helical Support Team,

I have encountered an issue when using dynamic SQL in Helical Insight.

I would like to ask how to properly write complex dynamic SQL in a metadata view.

For example, when using keywords such as DECLARE or WITH, the dynamic SQL execution fails with the following error: Error: [com.helicalinsight.efw.exceptions.EfwdServiceException: Couldn’t query the database, Couldn’t query the database, Incorrect syntax near ‘WITH’.]

Could you please advise on how to correctly implement complex dynamic SQL within a metadata view in Helical Insight?

Thank you in advance for your support.