简体   繁体   English

SSIS派生列表示

[英]SSIS Derived Column Expression

I have below derived expression for timestamp in SSIS 我在SSIS中有以下时间戳的派生表达式

(DT_DBTIME)(SUBSTRING([Column 11],1,2) + ":" + SUBSTRING([Column 11],3,2) + ":" + SUBSTRING([Column 11],5,2)) 

but it's not taking null values so I tried this one 但是它没有采用空值,所以我尝试了这个

ISNULL ( [Column 11] ) ? "000000" : (DT_DBTIME)(SUBSTRING([Column 11],1,2) + ":" + SUBSTRING([Column 11],3,2) + ":" + SUBSTRING([Column 11],5,2)) 

but still its not working. 但仍然无法正常工作。

Can anyone help on this? 有人可以帮忙吗?

The error that you posted in the question is a bit misleading. 您在问题中发布的错误有点误导。

The actual error produced in SSDT is : SSDT中产生的实际错误是:

The data types "DT_WSTR" and "DT_DBTIME" are incompatible for the conditional operator. 对于条件运算符,数据类型“ DT_WSTR”和“ DT_DBTIME”不兼容。 The operand types cannot be implicitly cast into compatible types for the conditional operation. 操作数类型不能隐式转换为条件操作的兼容类型。 To perform this operation, one or both operands need to be explicitly cast with a cast operator. 要执行此操作,需要使用强制转换运算符显式强制转换一个或两个操作数。

and ofcourse the one you posted at the end: 当然还有您最后发表的文章:

Error at Data Flow Task [Derived Column [18]]: Computing the expression "(ISNULL([Column 0]) ? "000000" : (DT_DBTIME) (SUBSTRING([Column 0],1,2) + ":" + SUBSTRING([Column 0],3,2) + ":" + SUBSTRING([Column 0],5,2)))" failed with error code 0xC00470A0. 数据流任务[派生列[18]]发生错误:计算表达式“(ISNULL([Column 0])?” 000000“:(DT_DBTIME)(SUBSTRING([Column 0],1,2)+”:“ + SUBSTRING([Column 0],3,2)+“:” + SUBSTRING([Column 0],5,2)))“失败,错误代码0xC00470A0。 The expression may have errors, such as divide by zero, that cannot be detected at parse time, or there may be an out-of-memory error. 该表达式可能有错误,例如被零除,在分析时无法检测到,或者可能有内存不足错误。

In your case this simply means that you cannot define (DT_DBTIME) to one part of the conditional operation, 就您而言,这仅意味着您无法将(DT_DBTIME)定义为条件操作的一部分,

Else Part 其他部分

: (DT_DBTIME)(SUBSTRING([Column 11],1,2) + ":" + SUBSTRING([Column 11],3,2) + ":" + SUBSTRING([Column 11],5,2)) :(DT_DBTIME)(SUBSTRING([Column 11],1,2)+“:” + SUBSTRING([Column 11],3,2)+“:” + SUBSTRING([Column 11],5,2))

leaving the other part as "DT_WSTR" 其余部分保留为“ DT_WSTR”

IF Part 中频部分

ISNULL ( [Column 11] ) ? ISNULL([第11列])? "000000" “000000”

So the correct Transformation rule should be: 因此正确的转换规则应为:

(DT_DBTIME)(IS( [Column 11] ) ? "000000" : (SUBSTRING([Column 11],1,2) + ":" + SUBSTRING([Column 11],3,2) + ":" + SUBSTRING([Column 11],5,2))) (DT_DBTIME)(IS([Column 11])?“ 000000”:(SUBSTRING([Column 11],1,2)+“:” + SUBSTRING([Column 11],3,2)+“:” + SUBSTRING ([第11栏],5,2)))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM