• Thanks to you both, great stuff! Those two approaches are the ways I assumed it could be solved, and they both work. By either wrapping in further statements and by using more explicit XML declaration. "Elements Absent" is a good pickup, I was aware of XSINIL but hadn't seen that one.

    Just a small change to your code Matt (yes it is just one ID at a time) to put the Value inside the ID element if it's present, i'll stick with that as it's a bit cleaner than wrapping.

    declare @id int

    set @id = null

    SELECT

    CASE WHEN @id is null

    THEN null

    ELSE 'Forehead Barcode' END

    AS [ID/IDType],

    RTRIM(@id) as [ID/Value]

    for XML PATH(''),TYPE, ELEMENTS ABSENT