Merging Values in a temporary table

  • Hi All,

    I know it may be a simple question but, presently cannot get my head around it.

    A stored procedure has a temp table (declare @temp table) which gets filled with the following values and sends it back to the application.

    col1 col2 col3 col4 col5

    00001 3123 3000 abc ppp

    00001 3123 3000 xyz 123

    00002 5656 4000 abc 654

    what I want the output is

    col1 col2 col3 col4 col5

    00001 3123 3000 abc - xyz ppp

    00002 5656 4000 abc 654

    Presently I do this in the the application which is too slow.. Can I do it in the sql writing some joins on the same table...

    Any help would be greatly appreciated..

    Thanks.

  • What is the criterion for merging? what happend to the value '123' which was in the column 5 of the second row?

    ..

  • There are a couple of concatenation methods (what you need to do this) along with some things to avoid in the following article...

    http://qa.sqlservercentral.com/articles/Test+Data/61572/

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.
    "Change is inevitable... change for the better is not".

    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)
    Intro to Tally Tables and Functions

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

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