• halifaxdal (8/18/2014)


    unfortunately CTE is not allowed in this particular staging table creation, and even if it is allowed, 10 million records would be a lengthy dump.:crazy:

    So use a temp table.

    Using that case statement (or a udf) in the group by is a recipe for causing your query to perform terribly.

    Dumping to a temp table will often solve that.

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events