Writing to a MySQL database from SSIS

出处  :  http://blogs.msdn.com/b/mattm/archive/2009/01/07/writing-to-a-mysql-database-from-ssis.aspx

7 Jan 2009 8:32 PM 

A couple of users reported being unable to use the ADO.NET destination to insert data into their mysql databases. When I originally tried this out, it worked, but it seems like changes made since the early 2008 CTPs have made us incompatible with MySQL. We do have a bug logged to make this more flexible, but the good news is that in the meantime there is a workaround when using the ODBC connector.

For the ADO.NET Destination to work properly, the MySQL database needs to have the ANSI_QUOTES SQL_MODEoption enabled. This option can be enabled globally, or for a particular session. To enable it for a single session:

  1. Create an ADO.NET Connection Manager which uses the ODBC driver
  2. Set the connection manager’s RetainSameConnection property to True
  3. Add an Execute SQL Task before your data flow to set the SQL_MODE – Ex. set sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,ANSI_QUOTES'
  4. Make sure that your Execute SQL Task and your ADO.NET Destination are using the same connection manager.

Setting the RetainSameConnection property to True will ensure that your Execute SQL Task and ADO.NET Destination are in the same session.

Note, I recommend using the ODBC Driver when writing to the MySQL database, because the MySQL .NET Connector has an additional blocking issue. If you try it out, you’ll get an error which looks something like this:

Error: 2009-01-05 12:03:47.79 
   Code: 0xC020844B 
   Source: Data Flow Task 1 Destination - Query [28] 
   Description: An exception has occurred during data insertion, the message returned from the provider is: You have an 
error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use nea 
r '"name", "date", "type", "remark") VALUES (p1, p2, p3, p4), (p1,p2,p3,p4), (p1,p2' at line 1 
End Error

Note that the “VALUES” portion has parameter names, and not the actual values. This appears to be an issue with the value the MySQL provider returns for its ParameterMarkerFormat. I did find a bug that was opened against them, but it looks like they decided not to fix it. I’ve heard that the DevArt dotConnect drivers do not have this problem, but I haven’t been able to try them out myself.

Writing to a MySQL database from SSIS的更多相关文章

  1. MySQL Database on Azure新功能

    本月中国版的MySQL Database on Azure发布了两项新功能: 1.主从复制——只读实例 在这之前Azure上的MySQL数据库也是支持主从复制的,但是只能作为on-premises部署 ...

  2. CentOS 7 安装 MySQL Database

    CentOS 7 安装 MySQL Database 1. 现在安装包,MySQL的安装包被分成了社区版和企业版,而本文将记录社区版本MySQL安装过程,下载MySQL版本如下: mysql-5.7. ...

  3. mysql-databaseython 3.4.0 with MySQL database

    Phttp://shttp://stackoverflow.com/questions/23376103/python-3-4-0-with-mysql-databasetackoverflow.co ...

  4. MySQL Database on Azure

    在国际版的Microsoft Azure上,MySQL服务是与ClearDB合作运营的.由于ClearDB无法在中国地区提供服务,因此微软中国的研发团队开发了专门面向中国市场的MySQL Databa ...

  5. MySQL Database on Azure 参数设置

    在使用MySQL过程中,经常会根据需要对MySQL的参数进行一些设置和调整.作为PaaS版本的MySQL,MySQL Database on Azure在参数设置方面有一些限制,客户不能像使用on-p ...

  6. MySQL Database on Azure 的用户名

    MySQL Database on Azure是中国版Windows Azure上的一个PaaS服务,类似于AWS上的RDS.MySQL Database on Azure的用户名与on-premis ...

  7. 迁移应用数据库到MySQL Database on Azure

    by Rong Yu 有用户问怎么把他们应用的数据库迁移到MySQL Database on Azure上,有哪些方式,有没有需要注意的地方.今天我们来概括介绍一下迁移应用数据库到MySQL Data ...

  8. MySQL Database on Azure - 利用PowerShell快速创建使用数据库服务

    如果您的应用需要通过脚本快速创建一个或多个MySQL数据库,MySQL Database on Azure目前开放了对于PowerShell的支持,可以帮助您快速利用自动化脚本进行数据库服务的创建.管 ...

  9. Windows Azure® 由世纪互联运营发布MySQL Database on Azure正式商用版

    我们很高兴宣布MySQL Database on Azure于2015年9月1日在中国地区正式商用.回望过去,从2014年12月对少量用户开放的预览试用,到2015年4月30日对中国用户全面开放的公共 ...

随机推荐

  1. LeetCode - 404. Sum of Left Leaves

    Find the sum of all left leaves in a given binary tree. Example: 3 / \ 9 20 / \ 15 7 There are two l ...

  2. SQLServer学习笔记系列12

    一.写在前面的话 这个sql学习系列,今天准备告一段落,虽然短短的十几篇文章,深刻感受到将学习的东西记录下来,是需要一种坚持! 这些东西只有反复的学习吸收,最终沉淀下来的才是属于自己的知识.也是提醒自 ...

  3. using语法糖详解 2015-01-06 17:45 50人阅读 评论(0) 收藏

    前段事件在using外套try catch 突然想到,如果出现异常 会不会执行释放,不执行的话那服务器很可能导致崩溃... 特意上了CSDN问了大神..得到了答案.. Using相等于try catc ...

  4. Java 实现批量重命名,亲测可用(精简版)

    之前在网上下载了很多视频,解压缩后,发现里面每个文件前面都有一长串的网址,导致我根本看不清每个视频的名字到底叫什么? 网上搜了一些批量重命名的方法,可都不是我想要的,既然这样,干脆自己动手用Java写 ...

  5. Compute Resource Consolidation Pattern 计算资源整合模式

    Consolidate multiple tasks or operations into a single computational unit. This pattern can increase ...

  6. 细说ASP.NET Core静态文件的缓存方式

    一.前言 我们在优化Web服务的时候,对于静态的资源文件,通常都是通过客户端缓存.服务器缓存.CDN缓存,这三种方式来缓解客户端对于Web服务器的连接请求压力的. 本文指在这三个方面,在ASP.NET ...

  7. 【翻译】设计模式学习系列1---【Design Patterns Simplified: Part 1【设计模式简述:第一部分】】

    原文链接:http://www.c-sharpcorner.com/UploadFile/19b1bd/design-patterns-simplified-part1/ Design Pattern ...

  8. StackExchange.Redis加载Lua脚本进行模糊查询的批量删除和修改

    前言 使用StackExchange.Redis没有直接相关的方法进行模糊查询的批量删除和修改操作,虽然可以通过Scan相关的方法进行模糊查询,例如:HashScan("hashkey&qu ...

  9. AbstractFactoryPattern(抽象工厂)

    /** * 抽象工厂模式 * 分为四部分 * 1.产品接口 * 2.产品实例 * 3.工厂接口(生产同一个产品的不同等级,这里是主要区别) * 4.工厂实例 * 工厂类最好用单例模式,但在这里主要是说 ...

  10. C#中==、Equals、ReferenceEquals的区别

    原文链接:http://www.studyofnet.com/news/1188.html 本文导读: C#中Equals , == , ReferenceEquals都可以用于判断两个对象的个体是不 ...