title: SQL Server: OPENXML vs SELECT..FROM when dealing with XML?
body: <p>I have this xml :</p>
  
  <pre><code>DECLARE @x XML
  SET @x = 
      '&lt;data&gt;
         &lt;add&gt;a&lt;/add&gt;
         &lt;add&gt;b&lt;/add&gt;
         &lt;add&gt;c&lt;/add&gt;
       &lt;/data&gt;';
  </code></pre>
  
  <p>Task :</p>
  
  <p>I want to list the  <code>a,b,c</code>.</p>
  
  <p><strong>approach 1 :</strong></p>
  
  <pre><code>SELECT s.value('.', 'VARCHAR(8000)') AS [ADD]
  FROM   @x.nodes('/data/add') AS t(s) 
  </code></pre>
  
  <p><strong>approach  2:</strong></p>
  
  <pre><code>DECLARE @idoc INT
  EXEC sp_xml_preparedocument @idoc OUTPUT, @x
  
  SELECT *
  FROM   OPENXML(@idoc, '/data/add', 2)
         WITH ([add] NVARCHAR(MAX) '.')
  </code></pre>
  
  <p>both of them give me : </p>
  
  <p><img src="https://i.stack.imgur.com/xFjA5.jpg" alt="enter image description here"></p>
  
  <p>question : </p>
  
  <p>which is the preferred way ?</p>
  
  <p>Is there any advantages of the latter vs former (  or vice verse) ?</p>