I have this simple Xml\[code\]set @p_Documentos='<documentos> <documento ID="1" IDTipoDocumento="1" IDTurma="144" IDEmpresa="1" /> <documento ID="2" IDTipoDocumento="1" IDTurma="144" IDEmpresa="9" /></documentos>'\[/code\]I have one attribute called IDDocumento that needs to be inserted in each of documento tags like this:\[code\]<documentos> <documento ID="1" IDDocumento="12" IDTipoDocumento="1" IDTurma="144" IDEmpresa="1" /> <documento ID="2" IDDocumento="34" IDTipoDocumento="1" IDTurma="144" IDEmpresa="9" /></documentos>\[/code\]then, i will tell how id tried to do it, first of all, i set one cursor that is something like:\[code\]DECLARE c_Documento FOR Select IDDocumento from Documentos\[/code\]In all interations of the cursor i tried to do this and a lot of variations that i dont exactly remenber:\[code\]SET @p_Documentos.modify('insert attribute IDDocumento { "sql:variable("@t_IDDocumento")" } into descendant::documento[not(@IDDocumento)][1]')\[/code\]It didnt worked, so i made one simple workaround:\[code\]SET @p_Documentos.modify('insert attribute IDDocumento { "0" } into descendant::documento[not(@IDDocumento)][1]')SET @p_Documentos.modify('replace value of (/documentos/documento[@IDDocumento="0"]/@IDdocumento)[1] with sql:variable("@t_IDDocumento")')\[/code\]if i test the selector with @p_Documentos.query method it finds exactly the targets that im trying to modify but for some reason this dosent work in "replace value of"the point is. I really wanted a solution for the first case and a explanation of why?!? to the second one. If there is no solution with the first case so at least someone help me fix the second one or show me better ways of doing it.