SQL to manipulate rows of data

  • @krenshau,

    Not sure if you got notification of an additional post so trying one more time. Did the code I post solve your problem? If not, let me know and I'll help you tweak it.

    --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)

  • Hello Jeff,

    Thank you for that code, I really appreciate it. Sorry, for the delay in getting back to you. One word, deadlines. :pinch: I was able to find a solution that is a little rough not at the database level, but in code. I tried the first solution, but I think I didn't understand it, and with the time crunch I just whipped up a workable solution in code. I think it is a little slow, but I can't spend anymore time on it right now. I want to revisit this part of the project after I meet our initial deadline, so I might be asking some more questions. I will study your solution in my spare time so I understand it better when I get back to that part of the project.

    Thanks again for your help. Sorry we got off on the wrong foot.

    Ben

  • Not to worry... and thanks for the feedback. 🙂

    If you want to learn more about the dynamic SQL Cross Tab I used, please see the following articles. Of course, questions are welcome.

    http://www.sqlservercentral.com/articles/T-SQL/63681/

    http://www.sqlservercentral.com/articles/Crosstab/65048/

    The first article explains what a Cross Tab is, how it can be used, and why it's better (IMHO) than PIVOT.

    The second article explains how to easily create dynamic Cross Tabs like the one in my code (although I did add a little 2k5 magic to this one).

    --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)

Viewing 3 posts - 16 through 17 (of 17 total)

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