• Try this:-

    SELECT

    (SELECT custname AS CustName

    , custcode AS CustCode

    FROM @test-2 t1 FOR XML PATH('Item'), TYPE)

    FOR XML PATH('Header'),ROOT('ns1')

    Follow me on twitter @EvoDBACheck out my blog Natural Selection DBA[/url]