Need help for split Multiple Columns into One column..

  • Hi,

    I have a Query Result like following

    id Name Mark1 Mark 2 Mark3 Mark4 mark 5

    ---------------------------------------------

    1 AAAA 75 85 45 65 85

    But i need result like

    Details

    -------

    1

    AAAA

    75

    85

    45

    65

    85

    How do i get Result..

    Please help me...

  • declare @t table(id int, Name varchar(100), Mark1 varchar(100), Mark2 varchar(100), Mark3 varchar(100), Mark4 varchar(100), mark5 varchar(100))

    insert into @t values(1, 'AAAA', '75', '85', '45', '65', '85')

    select

    id

    , Details

    from

    @t t

    unpivot (Details for field in (name, mark1, mark2, mark3, mark4, mark5)) unpvt

    ?

    all columns must have same type

    I Have Nine Lives You Have One Only
    THINK!

  • Thank you So much

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply