Online Advertising - Insurance Quotes - Free Articles Directory About Cancer - Debt Consolidation - Online Advertising

PDA

View Full Version : Retrieving BLOBs from SQL and saving to File System


MasterBeta
Nov 16th 2005, 8:35 am
So, I'm relatively new to SQL and it's eccentricities. I have a crap database that I inherited, this database was used by 1 individual to index all his files, word documents, spreadsheets, presentations, emails, images, etc, all as BLOBs. The client piece of this product is called scopeware and is not functioning. He wants all his files extracted from the SQL database and saved to the file system. I have looked around and found a few ways to extract these files and save them, primarily using ADO, but I can't find a good script samlple, I would appreciate any help from you folks.

Thanks.

Details: SQL Server 2000
BLOB Column Type: Image

hdpinn
Nov 26th 2005, 6:16 pm
Did you try just grabbing the data with a query and in the loop write the data to a file:

i'm lazy now so code may be sloppy and i just wrote it quick right here.

$query=mysql_query("select...");
$count =1;
while ($value = mysql_fetch_array($query)) {
$fp = fopen("myimagename" . $count . ".jpg", "w");
fputs($fp, $value['image_column_name']);
fclose($fp);

$count++;
}