Skip to content
Advertisement

Dynamic pivot unknown number of rows – Sql View

I’m using SQL to create a database VIEW from the table below.

I need to pivot the BcdName (for an unknown number of columns) and get the following result:

The solution found here: dynamic pivot issue in sql server 2012 is not working on a table View.

Advertisement

Answer

If you are willing to settle for defined columns with a “Warning/Undefined” column

Example

Returns

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