string concatination

  • Hi guys,

    Can any body help in below problem?

    Recordtype recidlocation

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

    prospect 123456location1

    prospect 123456location2

    prospect 123456location3

    Lead 123456location1

    Lead 123456location2

    lead 456789location1

    lead 456789location2

    lead 456789location3

    Result must be like

    Recordtype recidlocation

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

    prospect 123456location1,location2,location3

    Lead 123456location1,location2

    lead 456789location1,location2,location3

    Thanks in advance

  • Hi

    I got the solution. Thank you everybody

    SELECT recordtype, recid , REPLACE(RTRIM((SELECT location+']' + ' ' FROM

    temptable WHERE (recordtype = Results.recordtype and recid= Results.recid ) FOR XML PATH (''))),'] ',', ') AS NameValues

    FROM temptable Results GROUP BY recordtype, recid

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

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