• Eric Wahner-345205 (12/6/2012)


    @jcrawf02

    I think you confused my point with using a PIVOT vs dynamic PIVOT. When I said you have no choice, I was referring to doing a dynamic PIVOT. If you have unpredictable results you cannot write a PIVOT query without using dynamic sql to select the distinct rows that will ultimately be your columns.

    I'm not sure how that's any different than what you did, you just passed the list of fields to the CLR where I didn't bother to pass them, just collected them from available fields in the system and stuffed them back into the SQL query I constructed. I could make mine do what yours does, without having to use a CLR.

    Nice to know how to do it that way too, and well-written article, but it's not the *only* option.

    ---------------------------------------------------------
    How best to post your question[/url]
    How to post performance problems[/url]
    Tally Table:What it is and how it replaces a loop[/url]

    "stewsterl 80804 (10/16/2009)I guess when you stop and try to understand the solution provided you not only learn, but save yourself some headaches when you need to make any slight changes."