0

我一直在尝试使用 CASE--WHEN 将以下 SQL 代码转换为 SSIS 派生列表达式。该表达式将进入具有 varchar(5) 数据类型的新列中。

SQL 代码:

CASE
WHEN SUBSTRING(A.Column1,1,5) = 'John'
    OR 
    (C.Column1 IS NOT NULL
    AND A.Column2 = 'Two')
        THEN 'Two'  
WHEN SUBSTRING(A.Column1,1,5) = 'Mike'  
        THEN 'HD' 
WHEN D.Column1 IS NOT NULL
    AND F.Column1 IS NOT NULL
    AND G.Column1 LIKE '%DDD%'
    AND G.Column2 = H.Column1 
    AND H.Column2 = '1'
    AND H.Column3 = 'Y'
    AND H.Column4 <= A.Column3
    AND H.Column5 > A.Column3
    AND H.Column6 <= A.Column3
        THEN 'HE'  
WHEN B.Column1 IS NOT NULL
        THEN '' 
WHEN E.Column1 IS NOT NULL 
        THEN '22' 
ELSE ''

我的表达:

SUBSTRING([A.Column1],1,5) == "John" 
|| (ISNULL([C.Column1]) == FALSE 
&& ([A.Column2] == "Two") ? "Two":

(SUBSTRING([A.Column1],1,5) == "Mike" ? "HD":
(ISNULL([D.Column1]) == FALSE
    && ISNULL([F.Column1]) == FALSE
    && FINDSTRING([G.Column1], "DDD",1) > 0
    && [G.Column2] ==[H.Column1] 
    && [H.Column2] == "1"
    && [H.Column3] == "Y"
    && [H.Column4] <= A.Column3
    && [H.Column5] > A.Column3
    && [H.Column6] <= A.Column3 ? "HE":
(ISNULL([B.Column1]) == FALSE ? "":
(ISNULL([E.Column1]) == FALSE ? "22":""
))))

我是构建表达式的新手,并且无法找出我哪里出错了。我无法下载 Expression Tester 软件,因为我无法在工作计算机上运行 .exe。非常感谢任何帮助。

4

1 回答 1

0

您之前缺少右括号吗?“二”:

尝试这个:

SUBSTRING([A.Column1],1,5) == "John" 
|| (ISNULL([C.Column1]) == FALSE 
&& ([A.Column2] == "Two")) ? "Two":    
(SUBSTRING([A.Column1],1,5) == "Mike" ? "HD":
(ISNULL([D.Column1]) == FALSE
    && ISNULL([F.Column1]) == FALSE
    && FINDSTRING([G.Column1], "DDD",1) > 0
    && [G.Column2] ==[H.Column1] 
    && [H.Column2] == "1"
    && [H.Column3] == "Y"
    && [H.Column4] <= A.Column3
    && [H.Column5] > A.Column3
    && [H.Column6] <= A.Column3 ? "HE":
(ISNULL([B.Column1]) == FALSE ? "":
(ISNULL([E.Column1]) == FALSE ? "22":""
))))
于 2014-07-10T16:10:49.440 回答