• Follow the advice you were given in the OTHER thread, as in, stop using cast to varchar.

    These changes worked for me.

    drop function dbo.SelectChild

    go

    CREATE function dbo.SelectChild(@key as bigint)

    returns xml

    begin

    return (

    select

    CONVERT(varchar(100), CAST(enty_seq AS float)) as "@SeqNum",

    enty_key as "@EntityKey",

    chkp_cond as "@IsCheckpoint",

    (Select dbo.SelectChild(enty_key) for XML path(''),type) as "ListDirectChildren"

    from lubr_chkp

    where parent_key = @key

    order by enty_seq

    for xml path('entity'), type

    )

    end

    go

    WITH PrepareTable (XMLString)AS(SELECT

    CONVERT(varchar(100), CAST(enty_seq AS float)) as SeqNum

    ,enty_key AS EntityKey

    ,chkp_cond as IsCheckpoint

    ,(Select dbo.SelectChild(enty_key) for XML path(''),type) as ListDirectChildren

    FROM lubr_chkp

    WHERE parent_key = 64251705940

    order by enty_seq FOR XML PATH,TYPE,ELEMENTS)

    SELECT [XMLString]FROM[PrepareTable]

    ----------------------------------------------------------------------------------
    Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?