SSIS Conditional operator

  • I need to populate a column C based on two columns ( A and b) using SSIS.

    Below is the requirement .

    ColA ColB ColC

    DS NOT NULL DS

    DC NOT NULL E

    DC (Blank)

    Please help

  • I am not sure I follow what you are trying to accomplish.

    what do you want to do with ColA and ColB?

    what would the ultimate value of COLC be?

    If you can give an example of what the actual data would look like that would be helpful.

    Dan

    If only I could snap my figures and have all the correct indexes apear and the buffer clean and.... Start day dream here.

  • Would you mind explaining the requirements? I would have to assume what that means if I was to try and answer your question.



    Alvin Ramard
    Memphis PASS Chapter[/url]

    All my SSC forum answers come with a money back guarantee. If you didn't like the answer then I'll gladly refund what you paid for it.

    For best practices on asking questions, please read the following article: Forum Etiquette: How to post data/code on a forum to get the best help[/url]

  • If Cola = "DS" and ColB Is not null then colc ="DS"

    If Cola = "DC" and ColB Is not null then colc ="E"

    If Cola = "DC" and ColB Is null then colc =""(Blank)

    Where ColA and colB is there in the source and ColC is populated in the destination table based on the above conditions .

    thanks

  • You might want to take a look at the CASE statement.

    I also would like to recommend that you take some time to learn a few things about SQL Server before posting your next question. You remind me of someone heading down the driveway in a car then, before running into passing cars, asking: "How do I stop?" If you're going to use a technology, take the time to learn about it.



    Alvin Ramard
    Memphis PASS Chapter[/url]

    All my SSC forum answers come with a money back guarantee. If you didn't like the answer then I'll gladly refund what you paid for it.

    For best practices on asking questions, please read the following article: Forum Etiquette: How to post data/code on a forum to get the best help[/url]

  • In case you are looking to do this in SSIS and not SQL, you're looking for the conditional operator (which, if you used that in a google search, it would have hit right near the top :S).

    Steve.

  • stevefromOZ (9/1/2010)


    In case you are looking to do this in SSIS and not SQL, you're looking for the conditional operator (which, if you used that in a google search, it would have hit right near the top :S).

    Oops, I missed that in the topic.

    I agree with Steve



    Alvin Ramard
    Memphis PASS Chapter[/url]

    All my SSC forum answers come with a money back guarantee. If you didn't like the answer then I'll gladly refund what you paid for it.

    For best practices on asking questions, please read the following article: Forum Etiquette: How to post data/code on a forum to get the best help[/url]

  • Alvin Ramard (9/1/2010)


    You might want to take a look at the CASE statement.

    I also would like to recommend that you take some time to learn a few things about SQL Server before posting your next question. You remind me of someone heading down the driveway in a car then, before running into passing cars, asking: "How do I stop?" If you're going to use a technology, take the time to learn about it.

    Well said...

    Raunak J

  • Alvin Ramard (9/1/2010)


    stevefromOZ (9/1/2010)


    In case you are looking to do this in SSIS and not SQL, you're looking for the conditional operator (which, if you used that in a google search, it would have hit right near the top :S).

    Oops, I missed that in the topic.

    I agree with Steve

    I think the most important fact has been left out 🙂

    Do this in the Derived Column transformation.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • true true, i guess with only half a question asked, we'd give only half an answer 😉

    Steve.

  • stevefromOZ (9/2/2010)


    true true, i guess with only half a question asked, we'd give only half an answer 😉

    :-D:cool:

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • I must have been more tired than I thought when I first answered this one.



    Alvin Ramard
    Memphis PASS Chapter[/url]

    All my SSC forum answers come with a money back guarantee. If you didn't like the answer then I'll gladly refund what you paid for it.

    For best practices on asking questions, please read the following article: Forum Etiquette: How to post data/code on a forum to get the best help[/url]

  • If i understood you correctly, you would like to use SSIS to implement conditions and populate Column C

    Use Derived Column in SSIS

    and following is the expression to be used

    (ColA == "DC" && ColB != "NULL" ? "E" : "") + (ColA == "DS" && ColB != "NULL" ? "DS" : "") + (ColA == "DC" && ColB == "NULL" ? "" : "")

    Thanks

    BeginnerBachi

  • Bachi, not sure that'll work as written. Equality (or inequality) to NULL as a string is likely to fail when the value is actually NULL 🙂

    Using the SSIS Expression function ISNULL would work as you intended.

    Steve.

  • Yes , what you said is correct ..thanks 🙂

Viewing 15 posts - 1 through 15 (of 17 total)

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