MySQL Forums
Forum List  »  Microsoft SQL Server

Re: horrible ms sql export error
Posted by: Josh Chamas
Date: September 26, 2004 07:17AM

You can write a program that will read in the data in raw format, and move the data into MySQL that way. For example in Perl you might do something like:


# ( see for free Perl for windows )
# This sample code comes with no warranties, nor is guaranteed to even do anything useful
# nor even work, its just a method example for doing a quick data transfer.

use DBI;
use DBD::ODBC;
use DBD::mysql;

my $mssql_dbh = DBI->connect('dbi:ODBC:DSN_NAME', $user, $pass, { RaiseError => 1 });
my $mysql_dbh = DBI->connect('dbi:mysql:host=HOST_NAME;database=DB_NAME', $user, $pass, { RaiseError => 1 });

my $export_sth = $mssql_dbh->prepare("select col1, col2 from TABLE_NAME");
while(my $row = $export_sth->fetchrow_array) {
my($col1, $col2) = @$row;
$mysql_dbh->do("insert into TABLE_NAME (col1, col2) values (?,?)", undef, $col1, $col2);


Josh Chamas
Director, Professional Services
MySQL Inc.,
Get More with MySQL!

Options: ReplyQuote

Written By
September 23, 2004 09:45AM
Re: horrible ms sql export error
September 26, 2004 07:17AM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.