Search code examples
xmlsql-server-2008sqlxml

XML Insert attribute


When I update an xml column:

SET XmlDocumentData.modify('insert attribute User {sql:variable("@User")} 
    as last into (/Configuration/Process/Tasks)[1] ')

I am getting an error:

Msg 6905, Level 16, State 3, Line 27 XML Validation: Attribute 'User' is not permitted in this context. Location: //@*:User

What is a way to add new attributes in every task?


Solution

  • I guess that the column XmlDocumentData is bound to a Schema Collection and that the User attribute is not allowed in the Tasks node. Keep in mind that XML is case sensitive.