Skip to content

Migrating MySQL DB to MSSQL 2000

Well, I never thought that I would do such a thing, but I have a project that I am working on to develop an e-commerce website, but a segment of it requires 100% uptime. The site was built on a standard LAMP platform, and the 100% was kinda dropped on me after about 99% of the work being complete. So, a decision needed to be made.

Microsoft to the rescue?

*sigh* I hate to say it, but the file system clustering in Windows 2003 and the replication in MS-SQL 2005 is top rate, it really is. Simple and easy to setup. I can have the file system clustered in a matter of *literally* 5 clicks, MS-SQL replication in 3. File system and SQL replication is painful in Linux, and to date I haven’t gotten it to work.

MS SQL, really?

Clustering MySQL in a semi-reasonable way doesn’t exist. I found this tutorial, which is the best I’ve seen…but, the problem is what happens when the master server comes back online? MS-SQL Server 2000 (not 2005) seems to handle that quite well. Migration to MS-SQL was pretty easy, I followed these directions, and it when off without a hitch. Except that we needed to fix a few of the tables. Most (if not all) the tables in MySQL did not allow for NULL. However, we were inserting into it with “default” values…which didn’t transfer to MS-SQL so it wouldn’t “add” the data (tables were fine). So, we had to fix the databases in MySQL to let non-required info to allow NULL. As soon as we did PRESTO it migrated perfectly.

Update: After testing this migration with a MS-SQL Server 2000, I assumed that SQL server 2005 would have the same import options. Well, it doesn’t MS-SQL 2005 does not have an “ODBC Import” option. A *big* oversight in my opinion. Plus, as MySQL is probably the biggest threat to Microsoft, you would think that they would have an “Import from MySQL” as well. They don’t…really dumb.

IIS?

Short answer…hell no. I opted to go for Apache 2.2 with PHP 5.2.2. I attempted to get IIS 6 to work..for 6 hours, however it was a a nightmare to get it going (never did). Everything installed well, but when you tried to view a php page it returned a 404. So, I opted to stick to Apache with PHP. It installed very easy, and haven’t had any issues.

Your code man, what about the code!!

The code work almost immediately, mainly thanks to ADOdb. However, we ran into a few issues:

1. The money_format function doesn’t work in Windows. That had to be replaced, we decided to use number_format and just manually add the $

2. LIMIT doesn’t work in MS-SQL. We had to swap those out for some other method. Not sure what we did..that’s Mark’s Dept.

3. For some reason you have to specify $db->SetFetchMode(ADODB_FETCH_ASSOC) to have PHP return the associative array for DB queries (I didn’t have to do that for UNIX). I don’t know why, but I haven’t really researched it…don’t care really.

All and all I have had a good experience porting the PHP code base to Windows/MS-SQL. I’m still a Linux fan, and I have no doubt Linux will catch up. But, in the meanwhile this will do nicely.

Post a Comment

Your email is never published nor shared. Required fields are marked *
*
*