Introduction

This SQL Script converts rows to columns Using Dynamic Pivot to simulate a Dynamic Database Structure.

Scenario

We have decided to build a dynamic database by creating only the three below tables:

The current data

 

 

The desired data

How to use the Script

 

SQL
Edit|Remove
exec Convert_Rows_To_Columns_ByPivot 1 -- 1 is the Table ID

Output

For more details check SQL Script: Convert Rows To Columns Using Dynamic Pivot In SQL Server.