• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
PowerCoder
博客园    首页    新随笔    联系   管理    订阅  订阅

Retain NULL values vs Keep NULLs in SSIS Dataflows - Which To Use? (转载)

There is some confusion as to what the various NULL settings all do in SSIS. In fact in one team where I worked we had created 15 packages before realising the full implications of the various default settings. Anyway, hopefully this article will help to clarify a bit......

Suppose you are doing a bog-standard import of a text file like the one below. We have a data flow task with a flat-file source going to a OLEDB destination. The flat file contains 3 columns: MyDate, MyInt and MyText. In the file there are 2 rows - one containing normal values and the other one just containing blank column values. So, what happens in the case of a blank value?

By default, what will happen is shown in the first dataset below (2nd row). A blank date will become "1st Jan 1753", an integer will become "0" and text will become "". Is this what you want? Usually not - especially if "0" is also a legitimate explicit numerical value in the text file!

 

So, we can designate that the null values from the flat file (really an absence of a value) will become a null in the resulting OLEDB destination. There is a little checkbox on the flat file source which controls this:

The imported dataset will now look like this:

So far so good.

However there is another similar setting available here. This is a checkbox on the OLEDB destination labelled as "Keep NULLs" - what is that for?

Basically this controls what happens when you have defaults on the destination table. If there is a default constraint on each column –

eg

the date should be today's date,

the number should be -1

the text "n/a"

- do we want these default values to be overwritten by NULL values or to simply apply their specified defaults?

The relevant option is shown below. In this particluar case the defaults won't get applied and will be overwritten by NULLs from the source file.

If it was unchecked, and the defaults mentioned above existed, we would arrive at the values below.

Hopefully this makes these 2 setting and the various permutations s a little clearer

 

原文链接

 

posted @ 2018-04-27 14:59  PowerCoder  阅读(291)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3