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:

#!/usr/bin/perl

# ( see http://www.activatestate.com 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");
$export_sth->execute;
while(my $row = $export_sth->fetchrow_array) {
my($col1, $col2) = @$row;
$mysql_dbh->do("insert into TABLE_NAME (col1, col2) values (?,?)", undef, $col1, $col2);
}

$export_sth->finish;
$mysql_dbh->disconnect;
$mysql_dbh->disconnect;

Josh Chamas
Director, Professional Services
MySQL Inc., www.mysql.com
Get More with MySQL! http://www.mysql.com/consulting

Options: ReplyQuote


Subject
Written By
Posted
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.