shlogg · Early preview
Judy @esproc_spl

Easy Row-to-Column Transposition With EsProc SPL

We need to combine every 6 rows into one record, converting PROPERTY field values into new columns and maintaining original data types. SPL makes this task easy with dynamic requirements handling.

We have a database table FIRSTTBL. Below is part of its data:

And we are trying to combine every six rows into one record. Below is part of the desired result:

It is a row-to-column transposition – converting PROPERTY field values of every six rows into the new column attributes, and get non-null values under the original STRING, INTEGER, DATETIME, BOLLEAN and XML columns to assign them to the corresponding new columns (while maintaining the original data types).
SQL:

SELECT
            ID,
            FIRSTNAME,
            ...,
            FLAG = CAST (FLAG AS INT),
            ...
FROM...