Skip to content
Advertisement

How can I generate JSON results in older SQL Server versions?

I have a table which contains data similar to this. I want to get ItemNames in JSON format as I have mentioned in the expected output below.

Expected output:

Note: I know in latest SQL Server, there are functions FOR JSON to convert to JSON format but it won’t work in older SQL versions. Therefore, I am expecting the answer which should work on previous versions as well.

Advertisement

Answer

Something based on this?

enter image description here

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement