We help IT Professionals succeed at work.

PH copy tables from MSSQL to MYSQL

Jose Bredariol
on
Hi, I need php code to copy a table from MS SQL to MYSQL.
Comment
Watch Question

Dave BaldwinFixer of Problems
Most Valuable Expert 2014

Commented:
How are you currently accessing the MS SQL server?

Author

Commented:
I´m not accessing it yet. MSSQL is on my windows server (2008R2) and there we use asp and .net. Now I want some tables on my new server linux debian with php. I´m accessing MYSQL using :

 mysql_connect($hostname, $username, $password) or die(mysql_error());
 mysql_select_db("DATABASENAME") or die(mysql_error());
Dave BaldwinFixer of Problems
Most Valuable Expert 2014

Commented:
You should write a program that runs on the Windows Server to fetch the data you need and send it to your Linux server.  To get the data from a PHP program on your Linux server can be difficult.  You would first have to make sure that TCP/IP and remote connections are enabled on your MS SQL server.  Then you would have to struggle thru setting up FreeTDS on Linux.  And even then you may find that FreeTDS does not support all of the data types that are available in SQL Server 2008 and newer.

Author

Commented:
Yes,  TCP/IP and remote connections are enabled on your MS SQL server. I can´t do that on Linux using PHP ? Are you sure ?
Ahmed MerghaniSoftware Engineer
Commented:
Hi Jose Bredariol,

No need to write code for this task and instead, you can use a ready tool!
I think this tool is what you asking about:
http://www.mysql.com/products/workbench/
And there have a paper in how to do the migration:
http://www.mysql.com/why-mysql/white-papers/guide-to-migrating-from-sql-server-to-mysql/
Fixer of Problems
Most Valuable Expert 2014
Commented:
It is just more difficult than it should be.  There is no current driver for MS SQL on Linux unless you are running RedHat Enterprise.  The asker explains in this question http://www.experts-exchange.com/Programming/Languages/C/Q_27424576.html how he finally did it.  It does work and I have used his method.  But if you are using some of the newest data types in MS SQL, they will not be supported.  They also won't be a direct match to the data types available in MySQL.  Even Date/Time types are not exactly the same between the two systems.

Author

Commented:
Thanks all