Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. <History>
  2. <Entry>
  3. .....
  4. </Entry>
  5. <Entry>
  6. .....
  7. </Entry>
  8. </History>
  9.  
  10. <History>
  11. <Entry entryID="AAA">
  12. .....
  13. </Entry>
  14. <Entry entryID="BBB">
  15. .....
  16. </Entry>
  17. </History>
  18.  
  19. declare @eventId varchar(64)
  20. set @eventId = CONVERT(varchar(64),NEWID())
  21. update Histories
  22. set XmlHistory.modify('
  23. insert attribute EntryID {sql:variable("@eventId")}
  24. into (History/Entry)[1]
  25. ')
  26. where HistoryID=285162
  27.  
  28. select h.id rowPK, m.c.query('.') theElement
  29. from TheTable h
  30. cross apply h.XMLColumn.nodes('History/Entry[not(@EntryID)]') m(c)
  31. where XMLColumn.exist('(History/Entry)')= 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement