Skip to content
Advertisement

Dynamic Pivot Columns in SQL Server


I have a table named Property with following columns in SQL Server:

there are some property in this table that certain object in other table should give value to it.

I want to make a pivot table like below that has one column for each property I’ve declared in 1’st table:

I want to know how can I get columns of pivot dynamically from table. Because the rows in 1’st table will change.

Advertisement

Answer

Something like this:

SQL Fiddle Demo.

This will give you something like this:

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement