SSIS: Case clause with sintax error

  • Dear all,

    I am creating a derivated column task. It has a case in the expression but I always get the expression in red meaning that syntax is not correct.

    Can you please help?

    Here is the line that I added to the expression:

    (DT_STR,100,1252) (ISNULL([HEDGE CLASS CODE])? ( ISNULL([DC_ManagerCode] )? "FundCode" : "FundCode_ManagerCode_SHC") : "FundCode_SHC"))

    Goal is: if HEDGE CLASS CODE is null and DC_ManagerCode is null then:FundCode
                 if  HEDGE CLASS CODE is null and is NOT null then FundCode_ManagerCode_SHC
                 if   HEDGE CLASS CODE  is not null then FundCode_SHC

    Thank you

  • Might be easier to write a similar functioning CASE statement into your query source against your data.   However, one thing to look at is your data types. You may need to worry about typing the shorter string to a longer length, as that value is a constant, and may get typed with a shorter length.

    Steve (aka sgmunson) 🙂 🙂 🙂
    Rent Servers for Income (picks and shovels strategy)

  • Can you kindly check the syntax 

    Goal is: if HEDGE CLASS CODE is null and DC_ManagerCode is null then:FundCode--->(Why semicolon is used in front of column name)
    if HEDGE CLASS CODE is null and is NOT null --->(Why both null and not null used here!!!)then FundCode_ManagerCode_SHC
    if HEDGE CLASS CODE is not null then FundCode_SHC

    Saravanan

  • A quick look and you're opening more parenthesis than you are closing.The second left parenthesis closes the penultimate right parenthesis (the prior set was closed wrapping DT_STR,100,1252), leaving the last right parenthesis (on the end) with no corresponding left parenthesis. With nothing to test on, this is an "educated" guess, but perhaps try remove the trailing parenthesis.

    Blargh... My reads awfully... Parenthesis, Parenthesis, Parenthesis. ARGH!! THE PARENTHESIS MAN!!!

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
    Larnu.uk

  • Build your expression from the bottom up.  Does the inner condition ( ISNULL([DC_ManagerCode] )? "FundCode" : "FundCode_ManagerCode_SHC") work?  If so, the error must be in the outer condition.  I suspect the problem is the (DT_STR,100,1252) at the beginning.  You're attempting to convert a Boolean (something that returns True or False) into a string.  That's not necessary, and probably illegal.

    John

  • river1 - Monday, September 25, 2017 8:12 AM

    Dear all,

    I am creating a derivated column task. It has a case in the expression but I always get the expression in red meaning that syntax is not correct.

    Can you please help?

    Here is the line that I added to the expression:

    (DT_STR,100,1252) (ISNULL([HEDGE CLASS CODE])? ( ISNULL([DC_ManagerCode] )? "FundCode" : "FundCode_ManagerCode_SHC") : "FundCode_SHC"))

    Goal is: if HEDGE CLASS CODE is null and DC_ManagerCode is null then:FundCode
                 if  HEDGE CLASS CODE is null and is NOT null then FundCode_ManagerCode_SHC
                 if   HEDGE CLASS CODE  is not null then FundCode_SHC

    Thank you

    Looks like you have just one extra parenthesis at the right hand end of your formula.

    Steve (aka sgmunson) 🙂 🙂 🙂
    Rent Servers for Income (picks and shovels strategy)

  • sgmunson - Monday, September 25, 2017 8:23 AM

    Looks like you have just one extra parenthesis at the right hand end of your formula.

    Much simpler way of saying it. XD

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
    Larnu.uk

  • Unfortunately I don't think it is the parenthesis. I have removed one and the error is still there. I still see the expression in red 🙁

  • Sorry. It was realy the right parenthesis. Thanks for the support.

Viewing 9 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic. Login to reply