title: Count number of right truncated rows in bcp import
body: <p>I am trying count the no. of truncation errors that happens when bcp import is performed. I have tried a simple logic in which I redirect the output of bcp and then grep <code>right truncation</code> in that file. Following is the code snippet :</p>
  
  <pre><code>bcp Test..Table in datafile.txt -f format_file -m 0 -S server -T &gt; error_file.txt
  error_count=`cat error_file.txt | grep -c ".*right truncation.*" `
  </code></pre>
  
  <p>The problem is that <code>grep</code> takes too much time when there are many rows and moreover it takes more time even when there is no right truncation error. Is there a better way for this?
  I am using <code>bcp</code> utility in windows under <code>cygwin</code> and importing it into <code>MS SQL server 2008</code>.</p>