• I had something similar a while ago but not dynamic columns.

    In my case I was building a temp table from multiple data.

    What I did was create the table with all varchar columns plus a rowid.

    Insert the column names with rowid=1

    Insert the data (cast/convert) with rowid=2

    Select the data ordered by rowid.

    If you are pivoting with dynamic columns then you will know the column names, you could use the above technique.

    Far away is close at hand in the images of elsewhere.
    Anon.