Posted By

kashif21 on 04/14/11


Tagged

data element xml in insertion


Versions (?)

Xml element insertion in XML DATA


 / Published in: SQL
 

  1. Adding element INTO the XML DATA
  2. INSERT
  3. Expression1 (
  4. {AS first | AS last} INTO | after | before
  5. Expression2
  6. )
  7.  
  8. SET @xmlDoc.MODIFY('
  9. insert element UpdateDatetime {"2010-10-28T13:49:27.330"} before or after
  10. (/t/AuditID)[1]
  11. ')
  12. SET @xmlDoc.MODIFY('
  13. insert <UpdateDatetime>2010-10-28T13:49:27.330</UpdateDatetime>
  14. as last or as first or
  15. into(/t)[1]')
  16. IF (@xmlDoc.exist('/t/UpdateDatetime')=0)
  17. BEGIN
  18. SET @xmlDoc.MODIFY('
  19. insert <UpdateDatetime>2010-10-28T13:49:27.330</UpdateDatetime>
  20. as last
  21. into(/t)[1]')
  22. END
  23.  
  24. *Adding element WITH dynamic DATA FROM the sp parameters WITH condition.
  25.  
  26. IF (@xmlDoc.exist('/t/UpdateDatetime')=0)
  27. BEGIN
  28. SET @xmlDoc.MODIFY('
  29. insert element UpdateDatetime {sql:variable("@dtmCurrentDate")}
  30. as last
  31. into(/t)[1]')
  32. END

Report this snippet  

You need to login to post a comment.