Import SQL server data to mysql

Source: Internet
Author: User

During work, I encountered the problem of SQL Server Data importing to mysql. I checked the relevant information on the Internet. If mysqlodbc is used and other software is used for import, I need to install related plug-ins. My problem is only the import of a table in the database. I don't need to port the whole database, so I don't want to worry so much. So I tried the data format conversion method myself, fortunately, the problem has been solved, and it is quite simple. Let's share it with you.

Basic principles: SQL server data table ---> csv file ----> Import mysql database.

Steps:

1. Open sqlserver Enterprise Manager, select the table to be transplanted to the database, right-click and choose "all tasks"> "export data", and click Next as prompted. Click Next without changing the data source, purpose: "suffix" (remember that the suffix must be in csv format; otherwise, mysql cannot be imported). Click Next and follow the prompts to click the next step, when you go to the "select target file format" interface, select the data table to be exported in the source: drop-down box. Be careful here. Otherwise, the table you export will not be the data table you want, click next after the selection, and then click Next. The SQL Server data table is converted to a csv file.

2. At this time, the exported csv file cannot be directly imported into mysql, because the data does not have a header and needs to be modified. You can right-click the exported table in sqlserver Enterprise Manager and select "design table"

Copy information such as "column name", "Data Type", and "length" to the paper, use NotePad to open the exported csv file, press enter in the first line, and empty the first line, enter the copied column name in the following format: "ncid", "ncname", and "link" (the column name of the data table is enclosed by quotation marks and separated by commas), and save the column name, the csv file is modified. Create a directory named 1 on the desktop and put the csv file in the directory.

3. Use sqlyog to open mysql and select the database to be imported. If you do not create one in advance, right-click and choose Import (import) and select Import external data wizard, click Next, select csv from the data source type items, find the directory 1 created on the desktop, click Next, follow the prompts and click Finish to refresh the data table, in this way, a data table named CSV is imported into mysql and the data table name is modified, if necessary, you can also adjust the data type, length, and index key of the data table (these steps can be done by modifying the data table function through sqlyog). This completes the data table import.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.