SQL脚本到SSIS表达式 [英] SQL script to SSIS expression

查看:107
本文介绍了SQL脚本到SSIS表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有下面的T-SQL查询行,我想将其转换为Visual Studio SSIS表达式并转换为派生列任务。



所以 tableA [工作项目/提交编号#] 列,但在以下情况下,我需要将它们分成两列,如TableB中的 SubmissionCommon SubmissionNumber 被执行。

 案例
当ISNUMERIC(SUBSTRING([工作项/提交编号#,4,2))= 1时
THEN LEFT([工作项目/提交编号#],15)
ELSE LEFT([工作项目/提交编号#],16)
END AS提交共同,
[工作item / Submission no#] AS SubmissionNumber


解决方案

解决方案



我建议您首先添加一个派生列(您可以将其命名为 IsNumeric ,其表达式如下:

 (DT_NUMERIC,18,2)SUBSTRING([工作项/提交编号#,4, 2)==(DT_NUMERIC,18,2)SUBSTRING([工作项目/提交编号#,4,2)? 1:0 

然后在派生列转换编辑器窗口底部附近,单击配置错误输出。您需要告诉SSIS 忽略错误失败



添加另一个派生列,并使用以下表达式连接到第一个列

  REPLACENULL([IsNumeric],0)== 1吗? LEFT([工作项目/提交编号#],15):LEFT([工作项目/提交编号#],16)

因为第一个错误可能会引发错误



有关详细信息,请遵循本文:






  • 第一派生列





    第一派生列错误输出配置





    第二派生列




    I have the below T-SQL line of query that I'm trying to translate into Visual studio SSIS expression into derived column task.

    So tableA has just [Work item /Submission no#] column, but I need to split them into two column like SubmissionCommon and SubmissionNumber in TableB when below case is executed.

    CASE 
        WHEN ISNUMERIC(SUBSTRING([Work item /Submission no#], 4, 2)) = 1
           THEN LEFT([Work item /Submission no#], 15)
           ELSE LEFT([Work item /Submission no#], 16)
    END AS SubmissionCommon,
    [Work item /Submission no#] AS SubmissionNumber
    

    解决方案

    Solution

    I will suggested that you first add a derived column (you can name it IsNumeric), with the following expression:

    (DT_NUMERIC, 18, 2)SUBSTRING([Work item /Submission no#], 4, 2) == (DT_NUMERIC, 18, 2)SUBSTRING([Work item /Submission no#], 4, 2) ? 1 : 0
    

    Then near the bottom of the Derived Column Transform Editor window, click Configure Error Output. You need to tell SSIS to Ignore failure on Error

    Add another Derived Column connect to the first on with the following expression

    REPLACENULL([IsNumeric],0) == 1 ? LEFT([Work item /Submission no#], 15) : LEFT([Work item /Submission no#], 16)
    

    Because the first one may throws an error

    For detailed informations just follow this article:

    Update 1 - Screenshots

    Based on your comments, i will provide some screenshots

    Data Flow overview

    First Derived Column

    First Derived Column Error Output Configuration

    Second Derived Column

    这篇关于SQL脚本到SSIS表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆