title: Update Messages List By OpenXML in SQL
body: <p>I have a list of messages with xml format, I want to send message ID to stored procedure using OpenXML update their status to 'A' status. You can see coding here as follows: </p>
  
  <p>XML sample format:</p>
  
  <pre><code> &lt;Message&gt;
      &lt;MessageID&gt;17&lt;/MessageID&gt;
      &lt;MessageID&gt;16&lt;/MessageID&gt;
      &lt;MessageID&gt;15&lt;/MessageID&gt;
   &lt;/Message&gt;
  </code></pre>
  
  <p>In stored procedure:</p>
  
  <pre><code>exec sp_xml_preparedocument @idoc OUTPUT, @XmlMessagesItems  
  </code></pre>
  
  <p>Way 1:</p>
  
  <pre><code>UPDATE SECMSG_TO   
  SET SECMSG_TO.Status='A'
  FROM OPENXML (@idoc, '/Message',2) 
       with ( MessageID INT) ox  
  WHERE  
      SECMSG_TO.MessageID = ox.MessageID 
  </code></pre>
  
  <p>or way 2:</p>
  
  <pre><code>  UPDATE SECMSG_TO   
    SET SECMSG_TO.Status = 'A'
    WHERE SECMSG_TO.MessageID IN (SELECT *  
                                  FROM OPENXML  (@idoc, '/Message',2) 
                                  WITH ( MessageID INT)        
                              )
  </code></pre>
  
  <p>But by both ways I just can update first message means number 17 and other have not effected. Could you give me a clue how can I update all list completely.</p>
  
  <p>Thanks.</p>