MySQL 将数据从 My Sql 导入 Sql Server 的最简单方法
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/305886/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Easiest way to import data from My Sql to Sql Server
提问by Santiago Corredtheitroada
For a new project I have to import the pre-existing data from MySql.
对于一个新项目,我必须从 MySql 导入预先存在的数据。
In this siteI have found many options, some including the installation of drivers. What is the fastest & easiest way to do it?
在这个站点中,我发现了许多选项,其中一些包括安装驱动程序。什么是最快和最简单的方法?
Update: this would be just a one time import
更新:这只是一次导入
回答by Abdul HaSeeB
-- Create Link Server
EXEC master.dbo.sp_addlinkedserver
@server = N'MYSQL',
@srvproduct=N'MySQL',
@provider=N'MSDASQL',
@provstr=N'DRIVER={MySQL ODBC 5.1 Driver}; SERVER=localhost; _
DATABASE=tigerdb; USER=root; PASSWORD=hejsan; OPTION=3'
-- Import Data
SELECT * INTO testMySQL.dbo.shoutbox
FROM openquery(MYSQL, 'SELECT * FROM tigerdb.shoutbox')
回答by marcin.golebiowski
To convert MySQL to MS SQL Server
database you can use Microsoft SQL Server Database Migration Assistant
要转换MySQL to MS SQL Server
数据库,您可以使用Microsoft SQL Server 数据库迁移助手
回答by Adam
If you have access to phpMyAdmin you could run an export of the entire database. It will generate a long list of SQL commands to create all the schema and optionally insert all the data into their respective places.
如果您有权访问 phpMyAdmin,则可以运行整个数据库的导出。它将生成一长串 SQL 命令来创建所有模式,并可选择将所有数据插入到各自的位置。
It is also possible to perform all this from the command line.
也可以从命令行执行所有这些操作。
If you have a lot of data you may want to do it all in pieces, single SQL scripts for each table and the inserts into each.
如果您有大量数据,您可能希望分块完成,每个表的单个 SQL 脚本和每个表的插入。
Then on the M$ SQL side just create the database, connect to it with SQL Query Analyzer or SQL Management Studio, copy-n-paste your SQL scripts into the window and execute.
然后在 M$ SQL 端创建数据库,使用 SQL 查询分析器或 SQL Management Studio 连接到它,将您的 SQL 脚本复制粘贴到窗口中并执行。
Chances are a majority of your MySQL code will just work in M$SQL. If you run into issues, you can set a compatibility level on the MySQL export to fit your destination environment better.
很有可能你的大部分 MySQL 代码只能在 M$SQL 中工作。如果遇到问题,您可以在 MySQL 导出上设置兼容性级别以更好地适应您的目标环境。
If your just doing data, as long as the schema's match up, all you have to script is the data import/export, don't script the schema and CERTAINLY DON'T script drops!!!
如果您只是在处理数据,只要模式匹配,您只需编写数据导入/导出脚本即可,不要编写模式脚本,并且绝对不要删除脚本!!!
EDIT: if you had to do any transformations, I believe you can export to M$ Excel, certainly to a CSV, then on the M$SQL import do your mappings and such.
编辑:如果您必须进行任何转换,我相信您可以导出到 M$ Excel,当然也可以导出到 CSV,然后在 M$SQL 导入中执行您的映射等。
回答by Eric Z Beard
My team recently did the opposite, SqlServer to MySql, using the MySql Migration Toolkit (for moving a Fogbugz install from Windows to Linux) and it worked very well. We had trouble with a tool called MSSQL2MySql, it didn't work so well. I'm not sure if the migration toolkit handles the opposite direction, but it might be worth a look.
我的团队最近做了相反的事情,从 SqlServer 到 MySql,使用 MySql 迁移工具包(用于将 Fogbugz 安装从 Windows 移动到 Linux)并且效果很好。我们在使用名为 MSSQL2MySql 的工具时遇到了麻烦,它运行得不太好。我不确定迁移工具包是否处理相反的方向,但它可能值得一看。