none
SSIS variable expression

    Question

  • Below is my ssis variable expression within a data flow task. User::comp variable is from the loop.  I need to pass this into the query below.  The and condition (and date_added >''2018-10-05') only needs to apply only when comp =49.  It kept getting the syntax error from it, can you help please, Thanks

    @[User::comp]  == 49 ?
    "select *
    from myorders
    where comp_id ="+ @[User::comp] +" 
    and date_added >''2018-10-05''" ? 
    "select *
    from myorders
    where comp_id ="+ @[User::comp] +""

    Wednesday, January 9, 2019 8:22 PM

Answers

  • Hi Vicki2017, 

    Is the problem solved? 

    If yes, please mark the helpful reply as answer, to help others find the solution easily. 

    If not, please let we know. 


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    • Marked as answer by Vicki2017 Thursday, February 7, 2019 7:32 PM
    Monday, January 14, 2019 5:00 AM

All replies

  • Change DataType of @[User::comp] to String

    And try below code

    @[User::comp]=="49"?"select *
    from myorders
    where comp_id ="+ @[User::comp] +" 
    and date_added >''2018-10-05''":"select *
    from myorders
    where comp_id ="+ @[User::comp] +""


    mohammad waheed

    Wednesday, January 9, 2019 8:51 PM
  • Hi Vicki2017, 

    You can also try this: 

    @[User::comp]==49?"select *
    from myorders
    where comp_id =49 and date_added >''2018-10-05''":"select *
    from myorders
    where comp_id ="+ (DT_WSTR, 10) @[User::comp] +""

    To learn more about conditional expression, please check this link:

    ? : (Conditional) (SSIS Expression)

    boolean_expression?expression1:expression2


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Thursday, January 10, 2019 4:56 AM
  • Thank you all
    Friday, January 11, 2019 2:50 PM
  • Hi Vicki2017, 

    Is the problem solved? 

    If yes, please mark the helpful reply as answer, to help others find the solution easily. 

    If not, please let we know. 


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    • Marked as answer by Vicki2017 Thursday, February 7, 2019 7:32 PM
    Monday, January 14, 2019 5:00 AM