• I still could not run your CTE due to type mismatch error. (I guess when you do CHAR concatenation in the recursive CTE you should cast to NVARCHAR). However, looks like your solution will not perform good enough anyway.

    Try this instead:

    SELECT HeaderKey

    ,STUFF((SELECT ', ' + RTRIM(CAST(f2.PurchaseOrderNumber AS VARCHAR(30)))

    FROM FreightContents AS f2

    WHERE f2.HeaderKey = f1.HeaderKey

    ORDER BY PurchaseOrderNumber

    FOR XML PATH ('')), 1, 2, '') AS PO_list

    FROM FreightContents AS f1

    GROUP BY HeaderKey

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]