title: Inserting XML documents into SQL Server 2008 database
body: <p>I need help inserting xml files into SQL Server 2008.</p>
  
  <p>I have the following SQL statement:</p>
  
  <pre><code>insert into dbo.articles(id, title, contents)
    SELECT  X.article.query('id').value('.', 'INT'),
          X.article.query('article').value('.', 'VARCHAR(50)'),
          X.article.query('/doc/text()').value('.', 'VARCHAR(MAX)')
     FROM (
       SELECT CAST(x AS XML)
       FROM OPENROWSET(
             BULK 'E:\test\test_files\1000006.xml',
             SINGLE_BLOB) AS T(x)
          ) AS T(x)
  CROSS APPLY x.nodes('doc') AS X(article);
  </code></pre>
  
  <p>which basically shreds an XML doc into a columns. However, I want to be able to insert all the files in a folder, and not manually specify the file, as in this case E:\test\test_files\1000006.xml</p>