將MySQL庫的錶轉入到MSSQL中的某個庫中(Employees下的Employees表 → pubs庫下)_2

 

將MySQL庫的錶轉入到MSSQL中的某個庫中(Employees下的Employees表 → pubs庫下, 此pubs下的表名是employee,不衝突),
方法大體如下幾個(另有其餘方法待補充),其餘  MSSQL to MySQL的之後也可體驗下.
     1)MySQL ODBC Connector(Link轉換)
     2)Navicat Premium
     3)MSSQL Server版本相對應的SQL Server Migration Assistant for MySQLmysql

--------------------------------------------------------------------------------------------------------------------------------------
本文按照下述步驟進行:
1. 安裝驅動(如以前安裝過MySQL 裏面會配帶安裝了驅動)
2. 配置ODBC驅動  
3. 創建MySQL與MSSQL的鏈接
4. 在2個數據表之間導入數據    
      select * into pubs.dbo.employees 
      from openquery(mysql,'select * from employees.employees')sql

--------------------------------------------------------------------------------------------------------------------------------------ide

 

Info 1)以前就已安裝好MySQL 8.0.18,查看MySQL版本:this

      

 

 

      

Info 2)查看MSSQL版本(爲了讀一些舊代碼從MSSQL2014轉到了MSSQL2008)spa

     SELECT SERVERPROPERTY('productversion'),
                    SERVERPROPERTY ('productlevel'),
                    SERVERPROPERTY ('edition'),
                    @@versionserver

     select @@version
     blog

 

 

--------------------------------------------------------------------------------------------------------------------------------------
 1)ODBC配置rem

Employees是剛配置(MSSQL2008, 64bit, 爲轉換MySQL表到MSSQL中去)              
       it

下面數據源有5個的是2019年配置(當時安裝MSSQL2014,,爲了BarTender鏈接Excel文件打印標籤用)
 io

 

 2)在MSSQL的SQL Server Management Studio的Query中輸入:

EXEC master.dbo.sp_addlinkedserver
@server=N'MYSQL',
@srvproduct=N'MySQL',
@provider=N'MSDASQL',
@provstr=N'DRIVER={MySQL ODBC 8.0 ANSI Driver}; SERVER=127.0.0.1; 
 DATABASE=Employees; USER=root; PASSWORD=123456; OPTION=3'

        

//點擊上面那個連接時,提示下面信息:

(7303問題,還沒找到根本的解決方法,稍後繼續...)
TITLE: Microsoft SQL Server Management Studio
------------------------------
Failed to retrieve data for this request. (Microsoft.SqlServer.Management.Sdk.Sfc)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&LinkId=20476
------------------------------
ADDITIONAL INFORMATION:
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
------------------------------
Cannot initialize the data source object of OLE DB provider "MSDASQL" for linked server "MYSQL". (Microsoft SQL Server, Error: 7303)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=10.50.1600&EvtSrc=MSSQLServer&EvtID=7303&LinkId=20476

 

 3)而後再向表中插入數據插表
     select * into pubs.dbo.employees     from openquery(mysql,'select * from employees.employees')

相關文章
相關標籤/搜索