locked
Column Values in a row RRS feed

  • Question

  • User-797751191 posted

    Hi

        In a table i  have 3 fields Field1,Field2,Field3. I want to display data of each Column value in a row.

    Field1-Field1 Value

    Field2-Field2 Value 

    Field3-Field3 Value 

    Thanks

    Tuesday, July 7, 2020 4:17 PM

Answers

  • User452040443 posted

    Hi,

    Try something like this:

    select
        ca.FieldName,
        ca.FieldValue
    from MyTable as t
    cross apply
    (
        select 'Field1' as FieldName, t.Field1 as FieldValue
        union all
        select 'Field2', t.Field2
        union all
        select 'Field3', t.Field3
    ) as ca

    Hope this help

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, July 7, 2020 5:16 PM