Transferring blob from One MSSQL Database to Another
Posted: Fri Aug 04, 2006 12:19 pm
Everah | Please use
Everah | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Please HELP!!!
I have the current need to move MS SQL Server 2005 data from an external server to a local host (e.g. shared) windows server. The environment is PHP and I do have the connections created for both external and internal databases.
The question is how to transfer the image blob to the local MS Sql Server database from the external MS Sql Server database. I am already able to process all the other fields within the database except the image (e.g. blob) field.
The jpg Ole header (e.g. JFIF exists there) data is within the file. Can anyone show me how to do this?
Example code selecting the data below:Code: Select all
// Specify the login info here. (later move to external file)
// Select from database first
$msserver = '999.99.999.999';
$usrname = 'myusername';
$passwrd = 'mypassword';
$database = 'mydatabase';
$table = 'mytable';
// Build SQL statement here that has the blob field (medium_photo)
// medium_photo is a jpg file 320 x 208
$sql = 'SELECT TOP 100 id, medium_photo FROM ' . $table;
// Open the MS Sql Server Connection
$result = opensqldata($msserver,$usrname,$passwrd,$database, $sql);
// $result declared global within opensqldata function
$nrows = mssql_num_rows($result);
function opensqldata($msserver,$usrname,$passwrd,$database, $sql) {
global $msserver, $usrname, $passwrd, $database, $sql, $result, $dbcon;
// Open the MS Sql Server Connection
$dbcon = mssql_connect($msserver,$usrname,$passwrd);
if ($dbcon) {
echo "<font color='blue'>Connection to $msserver was successful.</font><hr>";
} else {
echo "<font color='red'>Error: ".mssql_get_last_message()."</font><hr>";
} // End if ($dbcon)
// Specify database here
mssql_select_db($database);
// Build SQL statement here
// $sql = 'SELECT TOP 10 * FROM ' . $sel_table;
$result = mssql_query($sql);
return $result;
} // End function open-sql-dataEverah | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]