FOR XML PATH('') Problem

  • HI,

    I'm having a problem trying to get a value from a table to be output as an XML Element without a start tag.

    The code I am using is this, with the result set below...

    select RequestStatus as "retainedDataMessage/retainedDataPay/statusMessage/StatusResponse/requestStatus"

    FROM ##StatusUpdates

    FOR XML PATH('')

    Result Set

    invalidReq

    The problem I have is that I would like the invalidReq to be within it's own element (but without a start tag). So I would like it to look like the below..

  • You could try this:

    select '' as "retainedDataMessage/retainedDataPay/statusMessage/StatusResponse/requestStatus/InvalidReq"

    FROM ##StatusUpdates

    where RequestStatus = 'InvalidReq'

    FOR XML PATH('')

    There probably is a far better way to do it though, so keep the question open 😀

  • Thank you! That solved my problem. Will leave the question open incase anyone has other idea's.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply