Re: modify() Top-level attribute nodes are not supported Error



Instead of the EXPLICIT mode, look at the PATH mode in FOR XML.

Best regards
Michael

"BradR" <bdrhoa@xxxxxxxxx> wrote in message
news:1176233744.686999.266610@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On Apr 6, 8:50 pm, Kent Tegels <kteg...@xxxxxxxxxxx> wrote:
Hello BradR,

The sql:variable() function is what you'd need to resolve @xUpdate in
your
query (remember that @xUpdate is an attribute in XQuery). That said, if
you
try this:

set @xPerson.modify('insert sql:variable("@xUpdate") into /person[1]')

You'll be sadly disappointed. You can't use the sql:variable function to
inject XML into XML. And converting xUpdate to nvarchar(...) isn't going
to help you either for less obvious reasons.

IMHO don't use XMLDML for this, its just too much of a PITA. You're
better
off you write a SQLCLR function that does the insert for you.

Your milage may vary.

Thanks!
Kent Tegels
DevelopMentorhttp://staff.develop.com/ktegels/

I've been investigating this for a while. It looks like it's possible
to solve this problem with FOR XML EXPLICIT, but that looks really
messy. Can you point me to a useful SQLCLR example?

Thanks!



.



Relevant Pages

  • Re: modify() Top-level attribute nodes are not supported Error
    ... I thought I'd simplify this down to just the XML: ... DECLARE @xPerson XML, @xUpdate XML ...
    (microsoft.public.sqlserver.xml)
  • Re: modify() Top-level attribute nodes are not supported Error
    ... I thought I'd simplify this down to just the XML: ... DECLARE @xPerson XML, @xUpdate XML ...
    (microsoft.public.sqlserver.xml)
  • Re: modify() Top-level attribute nodes are not supported Error
    ... The sql:variablefunction is what you'd need to resolve @xUpdate in your ... query (remember that @xUpdate is an attribute in XQuery). ... inject XML into XML. ... off you write a SQLCLR function that does the insert for you. ...
    (microsoft.public.sqlserver.xml)
  • Re: XML EXPLICIT PROBLEM
    ... to use the FOR XML Path mode. ... you are using EXPLICIT mode or EXPLICIT mode at all. ... I am newbie in sql server and I am particular interested in sqlxml; ... jobid as, ...
    (microsoft.public.sqlserver.xml)
  • Re: Xquery xml size limit
    ... use the EXPLICIT mode that is much harder to author. ... SELECT '1' AS 'elem/@id' FOR XML PATH, ... You can reduce that to a single FOR XML expression, ... Error message is: Invalid ...
    (microsoft.public.sqlserver.xml)