我必须使用SSIS将数据从SQL Server移动到MySQL。我有this tutorial,但我在Visual Studio 2008中找不到ODBC Destination。是否有另一种方法将数据从SQL Server移动到MySQL?
答案 0 :(得分:1)
在SQL 2012中添加了ODBC目标.Visual Studio 2008(或真正的BIDS 2008)适用于SQL Server 2008和2008 R2,它们是先前版本。
但是,您仍然可以在2008年使用ODBC驱动程序和ADO.NET目标执行此操作。在此处详细了解:https://blogs.msdn.microsoft.com/mattm/2008/03/04/connecting-to-mysql-from-ssis/
米
答案 1 :(得分:0)
您可以尝试使用脚本任务将数据从SQL Server加载到MySQL
Public Sub Main()
Dim sSql As String = "select s.PROTOCOL_SUBJECT_ID, s.PROTOCOL_ID, s.SEQUENCE_NUMBER, s.ORGANIZATION_ID" & vbCrLf &
"from dim_subject s" & vbCrLf &
"where s.ORGANIZATION_ID <> 2"
Dim sCn As String = "Driver={MySQL ODBC 5.1 Driver};Option=3;Server=Server1;Port=3306;Database=DB1;User=User1;Password=Pass1;"
Dim cnMySql As New Data.Odbc.OdbcConnection(sCn)
cnMySql.Open()
Dim cn As New SqlClient.SqlConnection("Data Source=ResFinCt;Initial Catalog=OnCore;User ID=saddd;Password=dsfsf;")
cn.Open()
Dim cmd As SqlClient.SqlCommand = New SqlClient.SqlCommand(sSql, cn)
Dim dr As SqlClient.SqlDataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection)
While dr.Read
Dim PROTOCOL_SUBJECT_ID As String = dr.GetValue(dr.GetOrdinal("PROTOCOL_SUBJECT_ID")).ToString()
Dim PROTOCOL_ID As String = dr.GetValue(dr.GetOrdinal("PROTOCOL_ID")).ToString()
Dim SEQUENCE_NUMBER As String = dr.GetValue(dr.GetOrdinal("SEQUENCE_NUMBER")).ToString()
Dim ORGANIZATION_ID As String = dr.GetValue(dr.GetOrdinal("ORGANIZATION_ID")).ToString()
sSql = "insert into stg_subject(PROTOCOL_SUBJECT_ID, PROTOCOL_ID, SEQUENCE_NUMBER, ORGANIZATION_ID) values(" &
PROTOCOL_SUBJECT_ID & ", " &
PROTOCOL_ID & ", '" &
SEQUENCE_NUMBER & "', " &
ORGANIZATION_ID & ")"
Dim cmdMySql As New Odbc.OdbcCommand(sSql, cnMySql)
cmdMySql.ExecuteNonQuery()
End While
dr.Close()
cnMySql.Close()
Dts.TaskResult = ScriptResults.Success
End Sub