Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <History>
- <Entry>
- .....
- </Entry>
- <Entry>
- .....
- </Entry>
- </History>
- <History>
- <Entry entryID="AAA">
- .....
- </Entry>
- <Entry entryID="BBB">
- .....
- </Entry>
- </History>
- declare @eventId varchar(64)
- set @eventId = CONVERT(varchar(64),NEWID())
- update Histories
- set XmlHistory.modify('
- insert attribute EntryID {sql:variable("@eventId")}
- into (History/Entry)[1]
- ')
- where HistoryID=285162
- select h.id rowPK, m.c.query('.') theElement
- from TheTable h
- cross apply h.XMLColumn.nodes('History/Entry[not(@EntryID)]') m(c)
- where XMLColumn.exist('(History/Entry)')= 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement