Hi @Thomaskyle
Thank you for reaching out to us with your query.
As per your query the error message "Incorrect syntax near 'FOR'" indicates that the FOR
clause is not supported in the Dedicated SQL Pool of Azure Synapse Analytics.
However, the FOR
clause is supported in other SQL Server-based platforms, including Azure SQL Database and Azure SQL Managed Instance.
Reference: SELECT - FOR Clause (Transact-SQL)
In synapse dedicated SQL pool, you can use concat and string_agg functions and create Json data manually instead of using For JSON auto. I tried this with sample data.
Sample source data:
Query to convert the table data in Json format:
select concat('{',string_agg(concat('{id:"',id,'",name:"',name,'"}'),','),'}')
as JSON_data from tab1
Result:
Appreciate if you could share the feedback on our feedback channel. Which would be open for the user community to upvote & comment on. This allows our product teams to effectively prioritize your request against our existing feature backlog and gives insight into the potential impact of implementing the suggested feature.
Hope this helps. Do let us know if you any further queries.
If this answers your query, do click Accept Answer
and Yes
for was this answer helpful. And, if you have any further query do let us know.