等效的 SSIS 表达式 [英] Equivalent SSIS expression
问题描述
我无法将以下 SQL 转换为相应的 SSIS 表达式并将其转换为 DATE 格式
I am unable to convert the following SQL to a corresponding SSIS expression and cast it to DATE format
SUBSTRING(A.FILENAME,13,2)+'-'+SUBSTRING(A.FILENAME,15,2)+'-'+SUBSTRING(A.FILENAME,17,4)
这是我能得到的最好的
DT_DATE(SUBSTRING(@[User::V_LoadFileName],13,2)+'-'+SUBSTRING(@[User::V_LoadFileName],15,2)+''+SUBSTRING(@[User::V_LoadFileName],17,4))
有什么建议吗?
推荐答案
Ferdipux 的答案中格式化数据的原因是您的环境可能没有使用相同的 DATE 样式(即 YYYY/MM/DD vs YYYY/DD/MM).
The reasoning for the formatted data in Ferdipux's answer is that your environment may not be using the same style of DATE (i.e. YYYY/MM/DD vs YYYY/DD/MM).
此外,您的示例存在语法问题.SSIS 中的转换有点奇怪.在变量之前关闭括号.
Also, your example has syntax problems. Casting in SSIS is a little odd. You close your parenthesis BEFORE the variable.
(DT_BOOL)"0"
返回 FALSE
还要注意在 SSIS 中使用两个引号.因此,您可能需要在脚本中使用 '"'
才能工作.
Note also the use of TWO quotations in SSIS. So you will likely need to use '"'
in your script to work.
SSIS 中的一些强制转换示例:
Some examples of casting in SSIS:
<代码>( «类型» ) «表达式»(DT_I4)(DT_STR, «长度», «代码页» )(DT_DATE)(DT_BOOL)(DT_WSTR, «长度» )(DT_NUMERIC, «精度», «比例»)(DT_DECIMAL, «比例» )(DT_DBTIMESTAMP)
最后,如果可以,请使用 Expression Tester.让我设计自己的 SSIS 包变得非常容易.:D
Lastly, if you can, use the Expression Tester. Made life REALLY easy for me in designing my own SSIS packages. :D
http://expressioneditor.codeplex.com/
这篇关于等效的 SSIS 表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!