04-21-2021 09:52 PM
We need to merge multiple documents to single array and looking for help. Since it is ultra task, we are running out of options…
Input data:
[
{“Record”: “1”},
{“Record”: “2”},
{“Record”: “5”},
{“Record”: “4”},
{“Record”: “6”}
]
Expected Output:
[ “response”: [{“Record”: “1”}, {“Record”: “2”}, {“Record”: “5”}, {“Record”: “4”}, {“Record”: “6”}]
]
04-22-2021 09:05 AM
Thanks. but please see below, 40 documents went in and 0 out. if we put the write inside the while loop, it will write 40 documents in this case but we need the 40th document as the final result. if there is a way to take the last document, that will also help
04-22-2021 09:10 AM
@thilkip - what is generating the input documents?
04-22-2021 09:11 AM
a SQL snap gets the data from tables
04-22-2021 09:13 AM
SQL Server 2016 (13.x) and later has a “FOR JSON” clause:
You should be able to return the result set exactly how you want.
04-22-2021 09:14 AM
the data coming from DB2