Advertisement
Guest User

Untitled

a guest
Nov 2nd, 2018
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 1.21 KB | None | 0 0
  1. create table #tmp(id bigint primary key clustered, x xml)
  2.  
  3. insert into #tmp(id, x)
  4. values
  5. (
  6. 5708960193365165161,
  7. '<collaborator SPXML-FORM="x-local://wtv/wtv_collaborator.xmd">
  8. <id>5708960193365165161</id>
  9. <lastname>Фамилия1</lastname>
  10. <firstname>Имя1</firstname>
  11. <middlename>Отчество1</middlename>
  12. <email>фио1@mail.ru</email>
  13. <login>login</login></collaborator>'),
  14. (
  15. 5708960193365165162,
  16. '<collaborator SPXML-FORM="x-local://wtv/wtv_collaborator.xmd">
  17. <id>5708960193365165162</id>
  18. <lastname>Фамилия2</lastname>
  19. <firstname>Имя2</firstname>
  20. <middlename>Отчество2</middlename>
  21. <email>фио2@mail.ru</email>
  22. <login>login</login></collaborator>'),
  23. (5708960193365165163,
  24. '<collaborator SPXML-FORM="x-local://wtv/wtv_collaborator.xmd">
  25. <id>5708960193365165163</id>
  26. <lastname>Фамилия3</lastname>
  27. <firstname>Имя3</firstname>
  28. <middlename>Отчество3</middlename>
  29. <email>фио3@mail.ru</email>
  30. <login>login</login></collaborator>')
  31.  
  32. select * from #tmp
  33.  
  34. UPDATE #tmp
  35. SET x.modify('
  36.    replace value of(/collaborator/email/text())[1]
  37.    with "НовоеИмя@mail.ru"')
  38. where x.exist('/collaborator[id="5708960193365165162"]') = 1
  39.  
  40. select * from #tmp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement