Concatenate data from column rows - Gopi

  • I have this data in a table

    grpledger Confirm

    1A01 yes

    1A02 Yes

    1 A03 No

    2A22 No

    3A33 Yes

    3A36 No

    I also need to concatenate the ledgers by grp

    The result needs to look like this. How do I do this without a cursor or loop?

    grpledger Confirm

    1A01|A02|A03 Yes|Yes|No

    2A22 No

    3A33|A36 Yes|No

    All this needs to be done dynamically for the tables having more number of rows, please help.

  • This article by Wayne Sheffield should help you to get what you want.

    http://www.sqlservercentral.com/articles/comma+separated+list/71700/

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2

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

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