package variable error

San 121 Reputation points
2021-01-02T05:33:57.793+00:00

Hi Experts,

unable to figure out this error.

52835-image.png

SQL Server Integration Services
0 comments No comments
{count} votes

Answer accepted by question author
  1. Visakh 211 Reputation points Volunteer Moderator
    2021-01-02T15:49:46.847+00:00

    I think the variable v_Updated_Date is of type DT_I4 so you would need to cast it to varchar before you do the concatenation
    So modify the expression like

    "SELECT store_name
    FROM src
    where update_date > '" + (DT_STR,20,1252) @[User::v_Updated_Date] + "' order by rtl_loc_id"
    
    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Yitzhak Khabinsky 27,091 Reputation points
    2021-01-02T23:53:40.08+00:00

    The entire SQL Statement expression is of a UNICODE data type. That's why a proper casting is below:

    "SELECT store_name
     FROM src
     WHERE update_date > '" + (DT_WSTR,20) @[User::v_Updated_Date] + "' ORDER BY rtl_loc_id;"
    
    0 comments No comments

  2. Monalv-MSFT 5,926 Reputation points
    2021-01-04T02:37:16.027+00:00

    Hi @San ,

    We can use the following methods to solve this question:

    Method 1: Using Type Casts (DT_WSTR, <<Length>>) in expression builder.
    Expression1:
    "SELECT store_name
    FROM src
    WHERE update_date> '" + (DT_WSTR, 10) @[User::v_Updated_Date] + "' ORDER BY rtl_loc_id;"

    53083-va1.png
    52994-expressionbuilder.png

    Method 2: Changing the Data type of variable [User::v_Updated_Date] as String.
    Expression2:
    "SELECT store_name
    FROM src
    WHERE update_date> '" + @[User::v_Updated_Date] + "' ORDER BY rtl_loc_id;"

    53131-va2.png
    52995-expressionbuilder2.png

    Best Regards,
    Mona

    ----------

    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.