I am looking for a query with the native functions of SQL Server 2012 to extract the JSON from the column Value, and dynamically create columns, and I want to do this for different columns
I have multiple record
| ID | Data | Other |
| 122 | {"URL":"www.url.com","Icon":"some_icon","Facebook":"Fa_url"} | Test123 |
| 222 | {"URL":"www.url.com","Icon":"some_icon", Facebook":"Fa_url"} | test123 |
I need to this formate
| id | URL | Icon | Other | ||
| 122 | www.abc.com | Some_icon | Facebook_url | abc | test123 |
| 222 | www.abc.com | Some_icon | Facebook_url | abc | test123 |


Bryian TanRank #396 · 6.3K reputationPosted Jul 4, 2018, 8:51 PM EDT
Shrimant TelgaveRank #623 · 3.8K reputationPosted Jul 4, 2018, 2:50 AM EDT
Solution-1:
only you need to change the column name in the above query.
I hope this will help you to resolved your problem.
arvind baldaniyaRank #3,964 · 375 reputationPosted Jul 3, 2018, 10:06 PM EDT
arvind baldaniyaRank #3,964 · 375 reputationPosted Jul 3, 2018, 10:42 PM EDT
arvind baldaniyaRank #3,964 · 375 reputationPosted Jul 3, 2018, 10:58 PM EDT
arvind baldaniyaRank #3,964 · 375 reputationPosted Jul 4, 2018, 3:23 AM EDT
Gajanan ChavhanRank #1,825 · 812 reputationPosted Jul 3, 2018, 9:55 PM EDT
https://docs.microsoft.com/en-us/sql/relational-databases/json/convert-json-data-to-rows-and-columns-with-openjson-sql-server?view=sql-server-2017
Gajanan ChavhanRank #1,825 · 812 reputationPosted Jul 3, 2018, 10:11 PM EDT
Also I found similar links :
1) https://www.red-gate.com/simple-talk/blogs/sql-server-json-to-table-and-table-to-json/
2) https://stackoverflow.com/questions/33520910/transform-json-data-to-separate-columns