• Just rerun the SQL and attached the execution plan (which will hopefully help).

    ::edit::

    Looking at the execution plan (and I know very little about these), it looks like it's a sort that's taking the time.

    The only sort I can see is the ID (based on Row_Number) inside the CTE.

    I'm thinking (guessing, really) that an index on the OpcsProcCodeConcatenated field will help matters. Having said that, I don't want to just start dropping indexes onto the table based on a guess.