title: How to implement the interface IDataReader in order to process the data before being insert?
body: <p>I have a stored procedure which gives me a result set consisting of a <strong>single</strong> column which contains millions of unprocessed rows. I need to transfer these data to another server using SqlBulkCopy, but the problem is that I can't simply do the following:</p>
  
  <pre><code>using (var con = new SqlConnection(sqlConnectionStringSource))
  {
      using (var cmd = new SqlCommand("usp_GetUnprocessedData", con))
      {
          cmd.CommandType = CommandType.StoredProcedure;
          con.Open();
          using (var reader = cmd.ExecuteReader())
          {
              using (var sqlBulk = new SqlBulkCopy(sqlConnectionStringDestination))
              {
                  sqlBulk.DestinationTableName = "BulkCopy";
                  sqlBulk.BulkCopyTimeout = 0;
                  sqlBulk.BatchSize = 200000;
                  sqlBulk.WriteToServer(reader);
              }
          }
      }
  }
  </code></pre>
  
  <p>because data won't be processed at all.</p>
  
  <p>In my case, the nth row of the result set looks like this:</p>
  
  <pre><code>value1_n,value2_n,value3_n
  </code></pre>
  
  <p>where <code>n</code> is just a subscript I've introduced to distinguish between the various rows.</p>
  
  <p>In the destination table, which I've named <code>BulkCopy</code>, I'd like to have:</p>
  
  <pre><code>╔══════════╦══════════╦══════════╗
  ║  Field1  ║  Field2  ║  Field3  ║
  ╠══════════╬══════════╬══════════╣
  ║ Value1_1 ║ Value2_1 ║ Value3_1 ║
  ║ Value1_2 ║ Value2_2 ║ Value3_2 ║
  ║ ...      ║ ...      ║ ...      ║
  ║ Value1_n ║ Value2_n ║ Value3_n ║
  ╚══════════╩══════════╩══════════╝
  </code></pre>
  
  <p>I was being told to use a custom <code>DataReader</code> via an implementation of the <code>IDataReader</code> interface, in order to process data row by row before <code>SqlBulkCopy</code> copies the data from it, using <code>EnableStreamingProperty = true</code> to ensure that only a small amount of data are in memory, but I have no idea where to start.
  Can you help me, please?</p>