title: How do I select just a portion of huge binary (file)?
body: <p>My problem is this: I have the potential for huge files being stored in a binary (image) field on SQL Server 2008 (> 1GB). </p>
  
  <p>If I return the entire binary using a regular select statement, the query takes more than a minute to return results to my .NET program and my client apps time out. What I'm looking for is TSQL code that will limit the size of the data returned (maybe 300mb), allowing me to iterate through the remaining chunks and prevent timeouts. </p>
  
  <p>This has to happen in the SQL query, not in the processing after the data is returned.</p>
  
  <p>I've tried SubString, which MS says works with binary data, but all I get back is 8000 bytes maximum. The last thing I tried looked like this:</p>
  
  <pre><code>select substring(Package,0,300000000) 'package', ID from rplPackage where ID=0
  --where package is the huge binary stored in a image field
  </code></pre>
  
  <p>Data Streaming isn't really an option either, because of the client apps.</p>
  
  <p>Any ideas?</p>