Assign a variable (String) directly from Excel Source

  • Im trying to assign a variable (Period) via an execute SQL Task using an excel connection manager source:

    Select Top 1 F2 From [Sheet1$]

    Seems easy, parses and runs without a result set associated to it.

    As soon as I assign it to a variable (Period type String) I get an error:

    [Execute SQL Task] Error: An error occurred while assigning a value to variable "Period": "The type of the value being assigned to variable "User::Period" differs from the current variable type. Variables may not change type during execution. Variable types are strict, except for variables of type Object. ".

    Please help!

  • David,

    if your excel sheet has the F2 field formatted as date, you will get a 'datetime' type value from the select statement. If you want to have this value inside a string variable, you hav to cast/convert it yourself into the appropriate format, SSIS can't do this for you because it does not know which format to take.

    WM_HOPETHATHELPS

    Günter

  • Thanks for the help

    Was definitely the datatype in the excel source:

    Resolved by using CSTR(F2)

    Cheers

Viewing 3 posts - 1 through 2 (of 2 total)

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