I'm playing around with the FOR JSON features in SQL Server 2019, and I'm struggling with how to use that feature to create a JSON list without keys... so like just a straight-up list of values.
For example, say I have this SQL:
declare @years table (year int)
insert into @years values (2022),(2021),(2020)
SELECT year
FROM @years
FOR JSON AUTO
This creates output like so:
[{"year":2022},{"year":2021},{"year":2020}]
But how would I get it to create output like THIS instead:
[2022,2021,2020]
And I'm looking to do this without messy nested string replaces... but maybe that's the only way? Thanks a lot for any help!