title: Read XML data into SQL Server table
body: <p>I have xml like this (it contains more than 300k):</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;data&gt;
    &lt;kitap&gt;
      &lt;Adi&gt;Matematik +5 Yaş&lt;/Adi&gt;
      &lt;Barkod&gt;9786052342046&lt;/Barkod&gt;
      &lt;Resim&gt;http://xxxx.com.tr/Icerik/Gorsel/Urun/9786052342046.jpg&lt;/Resim&gt;
    &lt;/kitap&gt;
    &lt;kitap&gt;
      &lt;Adi&gt;Broke - Light (Ciltli)&lt;/Adi&gt;
      &lt;Barkod&gt;9786057944085&lt;/Barkod&gt;
      &lt;Resim&gt;http://xxx.com.tr/Icerik/Gorsel/Urun/9786057944085.jpg&lt;/Resim&gt;
    &lt;/kitap&gt;
  &lt;/data&gt;
  </code></pre>
  
  <p>I want to store data into a database table.</p>
  
  <p>Here is my T-SQL code:</p>
  
  <pre><code>INSERT INTO ddd (Adi,Barkod,Resim) 
      SELECT 
          X.kitap.query('Adi').value('.', 'nvarchar(1000)'),
          X.kitap.query('Barkod').value('.', 'nvarchar(1000)'),
          X.kitap.query('Resim').value('.', 'nvarchar(1000)')
      FROM 
          (SELECT 
               CAST(x AS XML)
           FROM 
               OPENROWSET(BULK 'C:\sil\b.xml', SINGLE_BLOB) AS T(x)
          ) AS T(x)
  CROSS APPLY 
      x.nodes('data/kitap') AS X(kitap);
  </code></pre>
  
  <p>but I get this error:</p>
  
  <blockquote>
    <p>Msg 8152, Level 16, State 13, Line 1<br>
    String or binary data would be truncated.</p>
  </blockquote>