Link to home
Start Free TrialLog in
Avatar of James Stone
James StoneFlag for United States of America

asked on

Move a MSSQL blob field to a MySQL blob field

I have an existing MSSQL blob field that I would like to "export" to a MySQL database.  I have a script that will display the existing blob field, but I am guessing that I need to "save" the image and then "import" them into the MySQL database.

I tried to use the display script to just insert, but I get a "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 2".
If I remove the blob fields from the insert(`STI_Image`&`STI_Large_Image`), it inserts the rest of the information into the table.

Any help would be appreciated.
InsertBlob.php
DisplayImages.php
Avatar of Tomas Helgi Johannsson
Tomas Helgi Johannsson
Flag of Iceland image

Hi!

In SQLServer Management Studio you could choose to export the data to file either as a CSV file or with INSERT statements and easily convert that insert statement to valid MySQL statements that you import with

mysql -u username -p userpass  the_database  <  the_insertscript.sql

Open in new window

or if you choose CSV format
then in the mysql console
LOAD DATA INFILE 'c:/tmp/myexport.csv' 
INTO TABLE mydatabase.mytable 
FIELDS TERMINATED BY ',' 
ENCLOSED BY '"'
LINES TERMINATED BY '\n'
IGNORE 1 ROWS;

Open in new window


Regards,
     Tomas Helgi
Avatar of James Stone

ASKER

Sorry I guess I worded what I am looking for wrong -- I am trying to do this with PHP.  I have an android device that has php/MySql (runs as localhost)  that I use as a warehouse scanner.  I am wanting to upload the MSSQL database info (filtered to specific items from a php form) into the android device.  The android device can hook to the internet to download, but then the device goes to the warehouse with no outside connection.  If I can get the MS info into a sql file using php, I could use php to read that file.
ASKER CERTIFIED SOLUTION
Avatar of Tomas Helgi Johannsson
Tomas Helgi Johannsson
Flag of Iceland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi!

Did you manage to solve this ?

Regards,
    Tomas Helgi
Sorry I ended up just exporting the files to a folder and saving the link in the database.  Thanks for your help.
Hi!

Please close this question as you see appropriate.

Regards,
     Tomas Helgi