none
merging multiple rows to a single row

    Question

  • hi im trying to merge multiple rows which are populating to a table.

    so i want to merge thoese values into single row.i dont have a common column or any other column.

    ex

    col

    Ab

    cd

    ef

    now to show this in a single row of same table same column as Abcdef

    Monday, September 30, 2013 7:14 AM

Answers

  • declare @t table(col varchar(10));
    insert into @t values('Ab'),('cd'),('ef');
    select * from @t
    
    select distinct stuff((select '' + col
    FROM @t FOR XML PATH('')), 1, 0, '' ) as col


    ESHANI. Please click "Mark As Answer" if a post solves your problem or "Vote As Helpful" if a post has been useful to you


    • Edited by Eshani Rao Monday, September 30, 2013 7:21 AM
    • Marked as answer by VJREDDY Monday, September 30, 2013 7:23 AM
    Monday, September 30, 2013 7:20 AM

All replies