title: Stream data into sql server database without buffering the whole data
body: <p>I have a Table Blob, which has a <strong>varbinary(max)</strong> as a column. Now I want to store data into the database using a Filestream. The data can be really big (in my case 1.5GB) so I dont want to load the whole data into a buffer. </p>
  
  <p>What I tried:</p>
  
  <pre><code>        using (FileStream fs = File.Open(@"BigData.iso", FileMode.Open))
          {
              using (SqlConnection conn = new SqlConnection())
              {
                  conn.ConnectionString = @"...";
                  conn.Open();
                  SqlCommand command = new SqlCommand("INSERT INTO Blob Values (@0, @1)", conn);
                  command.Parameters.Add(new SqlParameter("0", Guid.NewGuid()));
                  var sqlb = new SqlBytes(fs);
                  command.Parameters.Add(new SqlParameter("1", SqlDbType.VarBinary, -1)).Value = sqlb;
                  command.ExecuteNonQuery();
              }
          }
  </code></pre>
  
  <p>But I got an <strong>OutOfMemoryException</strong>, because SqlBytes initialze its buffer to the whole size of the data.</p>
  
  <p>I know there is a FILESTREAM feature from Microsoft, but I don't want to use it.</p>
  
  <p>Is there a way to achieve this?</p>