Below is schema of the data stored in SQL Server 2016 Database
+------------+-------------+
| CountryKey | CountryName |
+------------+-------------+
| 1 | USA |
| 2 | Japan |
| 3 | China |
| 4 | UK |
| 5 | Australia |
+------------+-------------+
And in the Store table the information is saved as JSON
+-------+-----------+
| Store | Countries |
+-------+-----------+
| A | [1,2] |
| B | [1,3] |
| C | [1,3,4] |
| D | [4,5] |
| E | [1,5] |
+-------+-----------+
This design is working fine when I want to filter data, for example I'm able to use OPEN_JSON to filter the stores based on CountryKey
But after filter - the requirement is to show Country Name instead of Country Key as shown below -
Desired Output
+-------+----------------+
| Store | CountriesName |
+-------+----------------+
| A | USA, Japan |
| B | USA, China |
| C | USA, China, UK |
| D | UK, Asutralia |
| E | USA, Australia |
+-------+----------------+
My Question is can this be achieved with SQL Query or need to process data with server side language e.g C#.
If yes syntax and references will help.