What is the fastest way to export files (blobs) stored in a SQL Server table into a file on the hard drive? I have over 2.5 TB of files (90 kb avg) stored as varbinary and I need to extract each one to a local hard drive as quickly as possible. BCP seems to work but it will take over 45 days with the speed I'm seeing, and I'm worried that my script will fail at some point because Management Studio will run out of memory.
相关问题
- Views base64 encoded blob in HTML with PHP
- SQL join to get the cartesian product of 2 columns
- sql execution latency when assign to a variable
- Difference between Types.INTEGER and Types.NULL in
- php PDO::FETCH_ASSOC doesnt detect select after ba
I tried using a CLR function and it was more than twice as fast as BCP. Here's my code.
Original Method:
CLR Method:
C# Code for the CLR function
I came here looking for exporting blob into file with least effort. CLR functions is not something what I'd call least effort. Here described lazier one, using OLE Automation:
You'll potentially need to allow to run OA stored procedures on server (and then turn it off, when you're done):
Using a programming solution is one way, but the concern in the original question that a script might fail if SSMS runs out of memory can be also addressed by creating a SQL Agent job for the task. This of course completely ignores the performance part of the question.