Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
If I do this:
SELECT * FROM someTable FOR JSON PATH
I get a single result.
I want each row of the table to output as a separate row containing the json for just that row.
Can that be done?
You can do this as a nested subquery. WITHOUT_ARRAY_WRAPPER will remove the [] around the JSON also
WITHOUT_ARRAY_WRAPPER
[]
SELECT json = ( SELECT p.* FOR JSON PATH, WITHOUT_ARRAY_WRAPPER ) FROM someTable p;
Add a comment
Never mind. I figured it out.
SELECT (SELECT * FROM someTable WHERE someUniqueColumn = p.someUniqueColumn FOR JSON PATH) FROM someTable p
SELECT (SELECT p.* FOR JSON PATH) FROM someTable p
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.