Home Forums SQL Server 2012 SQL Server 2012 - T-SQL Unpivot okay, but how do I extract one more piece of data from the column? RE: Unpivot okay, but how do I extract one more piece of data from the column?

  • The only rule is this:

    1. Symptom names are always in uppercase.

    The next column is usually Causality[n]

    3. The column after that is Relatedness[n].

    So a table could look like this:

    CREATE TABLE BadTox (

    PatientID INT,

    Cycle TINYINT,

    ALOPECIA TINYINT,

    Causality1 TINYINT,

    Relatedness1 TINYINT,

    BONE TINYINT,

    Bone_Specify VARCHAR(50),

    Causality2 TINYINT,

    Relatedness2 TINYINT,

    CARDIAC TINYINT,

    Causality3 TINYINT,

    Relatedness3 TINYINT

    ...)

    There could be a "Specify" after the Symptom column.

    From the looks of it, if I can figure out how to create the list in the VALUES part of the CROSS APPLY, this thing will work.

    Thanks!