• You don't have to convert/cast the data. Use "type" in the For XML clause.

    select (select 1 as Val for xml raw, type);

    If you don't use "type", it comes out as varchar, instead of as XML. That's documented in Books Online.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon