Tuesday 15 April 2014

sql - XML DML Replace with a Function Result -


I would like to dynamically replace the value of an XML element, in which the selected XML values ​​obtained from the table The replacement should be done by a function that I want to call. I can not find any clue to point me in the right direction ...

I have the code snippet (incomplete) which I believe is the right structure to use XPath I want to know that element, and XPath are interested in me (one or more), from there I have no idea how to remove the result of the function, and ideally a SQL: place in the column Give:

First of all, if you want to update the table data from a function, you do not have permission to do it. Can use proc You can dynamically send it to the 'Replacement value' statement (above from the syntax) and send the value with which you want to replace. There is some code to show what I try to say I am doing:

  create PROC changeXML @xmlPath nvarchar (max), - statement 'value of the value' @value nvarchar (max) - Start as new value @ path string ethics ( Maximum), @Saikal NVARAAR (Max); - Complete statement Modesty set the SET @ pathString = '(* + @ xmlpath +' text, change the value of ()) ([ ']' as well ( " '+ + value +' ')'; SELECT @pathString; - Create dynamic SQL and pass it passrescence. SET @sql = 'UPDATE [dbo] [Table withXmlData] SET a.modify ('' p @ '') '; - Dynamic SQL excel SP_X acutexclose @ SQL, execute 'NPP Encyclopedia (Max)', @ P = @ path string and  

then run some such process:

< Pre> EXEC [dbo]. [ChnageXML] @xmlPath = N'path to its xml value,'value = n'new value '

No comments:

Post a Comment