2014-07-10 57 views
0

我一直在試圖將以下SQL代碼與CASE - WHEN轉換爲SSIS派生列表達式。該表達式將放入varchar(5)數據類型的新列中。從SQL代碼的SSIS派生列表達式CASE..WHEN

的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。任何幫助不勝感激。

回答

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":"" 
)))) 
+1

謝謝你抓住的!除此之外,我的H.Column2是數字數據類型。所以,我也必須像這樣轉換數據類型:'[H.Column2] ==(DT_NUMERIC,1,0)1' – Meta747