Home > SQL Server Tips > SQL Server Management > Moving data between MySQL and SQL Server
SQL Server Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

SQL SERVER MANAGEMENT

Moving data between MySQL and SQL Server


Serdar Yegulalp, Contributor
06.29.2006
Rating: -2.67- (out of 5)


Expert advice on database administration
Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


If you use either MySQL or Microsoft SQL Server, odds are you're at least curious about trying out the competing product. Most of the time, SQL Server users are the ones interested in moving to MySQL to take advantage of a free, open source system -- but the reverse does happen. In this tip, I will examine some things you need to keep in mind when moving data between those two databases.

I assume you are not planning to share things like stored procedures or functions between the two databases because they are not cross compatible; you're just planning to share or convert data. How to deal with stored procedures or functions will be an upcoming feature on SearchSQLServer.com.

Data typing issues

The first and foremost, when you're moving between MySQL and SQL Server, consider how each program's data typing restrictions will affect what you're doing. One little gotcha is that MySQL and SQL Server may have similarly named data types with, in fact, radically different capacities.

SQL Server's VARCHAR data type, for instance, can hold up to 4,000 characters, while MySQL's VARCHAR can only hold up to 255 characters. If you were going from MySQL to SQL Server, that wouldn't be an issue, but if you were going in the other direction, you'd need to make a MySQL TEXT column to hold a SQL Server VARCHAR column. The folks at MySQL have a chart you can use to compare against the SQL Server data types to make appropriate conversion decisions. MySQL also has a chart of VB6 data types, which is handy if you're using a Visual Basic front end to access a MySQL data source.

Keep in mind VARCHAR and other character-based fields must be used in terms of characters -- not bytes -- due to Unicode conversion issues.

Normalization

Another issue that parallels data typing is data normalization -- whether the data you're converting is already consistent or not. If you've followed strong data typing standards, this isn't a problem: A d


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


RELATED CONTENT
SQL Server Competitors
SQL Server vs. MySQL: Syntax differences, similar GUIs
Dumping Microsoft SQL Server: MySQL, PostgreSQL attract big users
Face-off: MySQL, PostgreSQL and SQL Server go head to head
Forrester Research on Oracle Real Application Clusters
Getting BI with a little help from your friends
Lessons Learned: Working with Oracle stored procedures, applications and data
SQL Server 2005 bitmap index?
Oracle 10g priced to compete with SQL Server
Former Oracle DBA falls for SQL Server
CA swings at Oracle, SQL Server with Ingres
SQL Server Competitors Research

SQL Server Migration Strategies and Planning
Using Microsoft Hyper-V for SQL Server consolidation
Migrating to SQL Server 2008 and leveraging new features
The challenges of SQL Server consolidation
Testing a SQL Server environment before an upgrade
SQL Server Consolidation Fast Guide
SQL Server consolidation strategies and best practices
Does upgrading to SQL Server 2008 fit your business?
A guide to advanced new features in SQL Server Management Studio 2008, part 2
A guide to basic new features in SQL Server Management Studio 2008, part 1
SQL Server virtualization pros and cons: Weigh the performance impact

SQL Server Management
A first look at Microsoft SQL Server 2008 R2
Maintaining high availability of SQL Server virtual machines
Creating fault-tolerant SQL Server installations
Using Microsoft Hyper-V for SQL Server consolidation
Scaling up vs. scaling out with SQL Server 2008
Migrating to SQL Server 2008 and leveraging new features
Testing a SQL Server environment before an upgrade
Does upgrading to SQL Server 2008 fit your business?
Meeting business needs with SQL Server full-text search
Using dynamic management views to improve SQL Server index effectiveness

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary


ate field will convert to a date field, an integer field will convert to an integer field, and so on.

For instance, if you find that date and time values are being stored as freeform strings, stop and fix that problem first. The data present may already be polluted, and the last thing you want is to get all the way through the conversion only to discover you've copied data that wasn't worth copying in the first place.

Also, whenever you're correcting a problem like this, work on copies, never originals. You'll always benefit from having an untouched original copy to refer to in case something else goes wrong.

Migration tools

A plethora of tools are available for the actual data migration, depending on which way you're migrating. The best plan is to use the tools you are most comfortable using. For instance, if you have SQL Server experience, you'd be better off using SQL Server's own Data Transformation Services (DTS). As long as there's an ODBC driver available for a particular data source (yes, MySQL has one), you can shuttle data between any two sources easily, on demand or on a schedule. Its wizard-driven interface makes a great deal of the work relatively painless.

Another tool is MSSQL2MySQL, a Visual Basic script for converting from SQL Server or Access databases to MySQL. It's a command-line script, but there are a number of graphic interfaces available for it. MSSQL2MySWL also has a few drawbacks. For example, it doesn't provide any visual feedback during the conversion process. So, you may not want to use it for big databases that require a lot of processing.

For those on the MySQL side converting from SQL Server (who don't have much control over SQL Server but can access it an ODBC data source), you can use Webyog's SQLyog tool to do the conversion. It's functionally similar to SQL Server DTS, so former SQL Server users can probably wrap their minds around it without too much difficulty. Get a free trial edition. It may be just the thing you need to do the conversion alone.

About the author: Serdar Yegulalp is editor of the Windows Power Users Newsletter. Check it out for the latest advice and musings on the world of Windows network administrators -- and please share your thoughts as well!

More information from SearchSQLServer.com

  • Tip: MySQL vs. SQL Server
  • Column: SQL Server DBMS' growing popularity is no coincidence
  • Topic: Get more best practices on SQL Server integration and interoperability

  • Rate this Tip
    To rate tips, you must be a member of SearchSQLServer.com.
    Register now to start rating these tips. Log in if you are already a member.




    DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



    SQL Server Development - .NET, C#, T-SQL, Visual Basic
    HomeNewsTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersIT Downloads
    About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
    SEARCH 
    TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

    TechTarget Corporate Web Site  |  Media Kits  |  Site Map




    All Rights Reserved, Copyright 2005 - 2009, TechTarget | Read our Privacy Policy
      TechTarget - The IT Media ROI Experts