Transfer data from MSSQL to Mysql

Discussion in 'MySQL' started by rederick, Apr 12, 2006.

  1. #1
    Hi, Wondering if anyone can help me with this..

    I am running a linux server and I need to Query a MSSQL database. I have succesfully connected and Queried the MSSQL Database using
    freetds http://www.freetds.org/ and sqsh http://www.sqsh.org/

    What I need to do is have the sqsh software "dump" the data into a Text file that I can then import into MySql Database.
    I am able to "pipe" the results of the query into a .txt file, except it's not in the correct format :-(

    Does anyone have some advice ?

    Thank you
    Red.
     
    rederick, Apr 12, 2006 IP
  2. woodside

    woodside Peon

    Messages:
    182
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Is this something that needs to be done repeatedly or just once? Depending on your programming language and if you can connect to the mysql and mssql database from the same script, you could just query the one db, the loop through and insert it into the other db. Skip the write text file, read text file part. You could also look into creating a wddx packet and writing that to a file. What language are you using?
     
    woodside, Apr 12, 2006 IP
  3. rederick

    rederick Peon

    Messages:
    128
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I have actually just managed to get a connection to the MSSQL database using PHP. And that is excatly what I am doing now, I connect to the MSSQL Database, SELECT * FROM TABLE then loop through the results Inserting them into the MYSQL database. Problem now is the MSSQL database is HUGE and I PHP keeps running out of memory. :-(
     
    rederick, Apr 12, 2006 IP
  4. woodside

    woodside Peon

    Messages:
    182
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #4
    If there is some sort of id on the field you are selecting from, just do a limit (if you can with mssql) and grab a thousand rows at a time (or a bigger/smaller number).
     
    woodside, Apr 12, 2006 IP