I have this table named Employee I want to Pivot this into a new table:

That is into the new table dynamically means the number of attributes of JSON data can be changed dynamically:

How can I do in SQL Server 2017 dynamically?
I have this table named Employee I want to Pivot this into a new table:

That is into the new table dynamically means the number of attributes of JSON data can be changed dynamically:

How can I do in SQL Server 2017 dynamically?
You can use
OPENJSONwith a table definition for this.You only need to use
REPLACEto make it valid JSON