Update SQL Server table with XML

iTaChii

New Member
I have an XML variable that looks like this:\[code\]<code><IDs> <ID id="1">a</ID> <ID id="43">d</ID> <ID id="3">b</ID></IDs></code>\[/code\]I want to use that in a stored procedure (SQL Server) that will update a table. My table look like this:\[code\]ID INT,a INT,b INT,c INT,d INT\[/code\]The statement should increase the letter value associated with the id.SO it would look like this:\[code\]Table Row with ID = 1, update column "a" by increasing the current value by 1.Table Row with ID = 43 - update column "d" by increasing current value by 1.Finally Table row with ID= 3 - update column "b" by increasing value by 1.\[/code\]This is what I have so far - (The second line is where i need the most help.):\[code\]Update MyTableSET @letter = letterVal +1WHERE ID IN(SELECT x.v.value('@id','INT')FROM @xmlIDs.nodes('/IDs/ID') x(v))\[/code\]
 
Back
Top