I have this code working
UPDATE UserData
SET Data.modify('delete(/UsersData/UserXml[@user_id=23445])[1]')
WHERE Id = 11;
But when I try this code it throw ex
declare @myXmlQuery nvarchar(120)
set @myXmlQuery = '/UsersData/UserXml[@user_id=23445]'
UPDATE UserData
SET Data.modify('delete(sql:variable("@myXmlQuery"))[1]')
WHERE Id = 11;
I get this ex :
Msg 2264, Level 16, State 1, Line 11 XQuery
[UserData.Data.modify()]: Only non-document nodes may be deleted,
found ‘xs:string’
Any ideas ?
thanks.
A hacky way would be:
I’m sure the XML gurus will swing around with a more practical answer. I’m more of a relational guy. 🙂