howto copy over content from odbc databse to mysql

Posted on 2005-04-07
Last Modified: 2013-12-12
I would like to know how I can make a php script that copies over all data from a specifiek ODBC database or table in a database to a mysql database or table.

I know how to make a connection to an odbc source with the php function odbc_connect and a mysql source with mysql_connect, but what kind of query can I use to copy everything over?

Is it anyhow possible to do this with one simple query or do I need to use arrays?

Thanks in advance...
Question by:KGT
    LVL 1

    Accepted Solution

    You could use an sql select query with the ODBC connection, retrieve all the data from that table, then process it row by row and insert it into the MySQL table.  That would be my first idea on how to do this.

    Of course, the two tables would need to have the same structure otherwise you could run into problems.
    LVL 1

    Author Comment

    I was thinking the same thing. The structure is no problem, while I already setup several tables with the same structure in MySQL. All I need is some example code that could work, because I really don't know how to do it...
    LVL 1

    Author Comment

    LVL 5

    Assisted Solution

    If your ODBC source (suppose you're using SQL Server) can somehow access the MySQL DB, then a query like

    insert into mySQL.TABLE(field1, field2) select field1, field2 from SQL.Table

    could run, but I cannot make it work.

    What is the ODBC source?
    LVL 1

    Author Comment

    The ODBC source is a special format called PASSDATA from a company called MegaWorks. It came with a (slow) ODBC driver. This makes that queries throught the ODBC run very slow incomparison with the same queries in a mysql DB.

    I will give your solution a try...
    LVL 10

    Expert Comment

    No comment has been added to this question in more than 21 days,so it is now classified as abandoned..
    I will leave the following recommendation for this question in the Cleanup topic area:
    [Points Split {rmaranhao}and {robknowles}]

    Any objections should be posted here in the next 4 days. After that time, the question will be closed.

    Kshitij Ahuja
    EE Cleanup Volunteer

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Join & Write a Comment

    Suggested Solutions

    Both Easy and Powerful How easy is PHP? (  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
    Part of the Global Positioning System A geocode ( is the major subset of a GPS coordinate (, the other parts being the altitude and t…
    The viewer will learn how to count occurrences of each item in an array.
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    27 Experts available now in Live!

    Get 1:1 Help Now