title: SQL Server bulk insert fails, but file imports easily with import wizard
body: <p>I have an R script that combines years of FFIEC Bank Call Report schedules into flat files--one for each schedule--then writes each schedule to a tab-delimited, non-quoted flat file suitable for bulk inserting into SQL Server. Then I run this bulk insert command:</p>
  <pre><code>bulk insert CI from 'e:\CI.txt' with (firstrow = 2, rowterminator = '0x0a', fieldterminator = '\t')
  </code></pre>
  <p>The bulk insert will run for a while then quit, with this error message:</p>
  <pre><code>Msg 7301, Level 16, State 2, Line 4
  Cannot obtain the required interface (&quot;IID_IColumnsInfo&quot;) from OLE DB provider &quot;BULK&quot; for linked server &quot;(null)&quot;.
  </code></pre>
  <p>I've searched here for answers and the most common problem seems to be the rowterminator argument. I know that the files I've created have a line feed without a carriage return, so '0x0a' is the correct argument (but I tried '\n' and it didn't work).</p>
  <p>Interestingly, I tried setting the fieldterminator to gibberish just to see what happened and I got the expected error message:</p>
  <pre><code>The bulk load failed. The column is too long in the data file for row 1, column 1.&quot;
  </code></pre>
  <p>So that tells me that SQL Server has access to the file and is indeed starting to insert it.</p>
  <p>Also, I did a manual import (right click on database, tasks-&gt;Import Data) and SQL Server swallowed up the file without a hitch. That tells the layout of the table is fine, and so is the file?</p>
  <p>Is it possible there's something at the end of the file that's confusing the bulk insert? I looked in a hex editor and it ends with data followed by 0A (the hex code for a line feed).</p>
  <p>I'm stumped and open to any possibilities!</p>