I want my result set to include the "<" character within the node element name however the sql compiler is returning an invalid character err. msg. ("..contains an invalid XML identifier as required by FOR XML; '''(0x0027) is the first character at fault."). I've tried to use the "<" however that's not working either. Thanks for any suggestions. Below is a sample of the query: Select age, Male<250, Male<250 FROM #tmp FOR XML Path('Test')
AFAIK that's not allowed by the XML Recommendation. Characters like that are usually created using some special encoding like this: Male_x0027_250 Although that sort of defeats the purpose of what it appears you're trying to do here. You might consider something like this: Male_lt_250 Male_less_than_250 Or something similar to indicate what you're trying to express. -- ======== Michael Coles "Pro SQL Server 2008 XML" http://www.amazon.com/Pro-SQL-Server-2008-XML/dp/1590599837/ wrote in message news:bab11ca4-c67b-470e-8ec8-bb3dddcb5931@d1g2000hsg.googlegroups.com... >I want my result set to include the "<" character within the node > element name however the sql compiler is returning an invalid > character err. msg. ("..contains an invalid XML identifier as required > by FOR XML; '''(0x0027) is the first character at fault."). I've > tried to use the "<" however that's not working either. > > Thanks for any suggestions. > > Below is a sample of the query: > > Select > age, > Male<250, > Male<250 > FROM #tmp > FOR XML Path('Test')
Oops, "Characters like that are usually *encoded*" in element names... -- ======== Michael Coles "Pro SQL Server 2008 XML" http://www.amazon.com/Pro-SQL-Server-2008-XML/dp/1590599837/ "Michael Coles" <michaelcoREPLACE_THIS_WITH_AT_SIGNoptonline.net> wrote in message news:ueLAbtB0IHA.4476@TK2MSFTNGP06.phx.gbl... > AFAIK that's not allowed by the XML Recommendation. Characters like that > are usually created using some special encoding like this: > > Male_x0027_250 > > Although that sort of defeats the purpose of what it appears you're trying > to do here. You might consider something like this: > > Male_lt_250 > Male_less_than_250 > > Or something similar to indicate what you're trying to express. > > > -- > > ======== > Michael Coles > "Pro SQL Server 2008 XML" > http://www.amazon.com/Pro-SQL-Server-2008-XML/dp/1590599837/ > > > wrote in message > news:bab11ca4-c67b-470e-8ec8-bb3dddcb5931@d1g2000hsg.googlegroups.com... >>I want my result set to include the "<" character within the node >> element name however the sql compiler is returning an invalid >> character err. msg. ("..contains an invalid XML identifier as required >> by FOR XML; '''(0x0027) is the first character at fault."). I've >> tried to use the "<" however that's not working either. >> >> Thanks for any suggestions. >> >> Below is a sample of the query: >> >> Select >> age, >> Male<250, >> Male<250 >> FROM #tmp >> FOR XML Path('Test') > >