Search code examples
sql-servercsvssisetlflat-file

SSISDB package errs out, says variable does not exist


I have an SSIS package that writes csv files from a database, copies them to a couple locations, and then emails a success message. The process is:

  1. Retrieve public file location from database into a variable, @[User::varSQLCSVOutputFolder]
  2. Loop through a list of database records:
    • Create a local CSV for each one.
    • Copy the local file to the location in @[User::varSQLCSVOutputFolder]
  3. Send email with MessageSource defined in @[User:varEmailBody].
@[User::varEmailBody] = "Files successfully saved to " + @[User::varCNNTargetCSVFolder]

@[User::varCNNTargetCSVFolder] = @[User::varSQLCSVOutputFolder]

@[User::varSQLCSVOutputFolder] loads from the database, value = \\server.domain.com\TEST\Output Files AM

(to confirm, @[User::varCNNTargetCSVFolder] is just a pass-thru)

I can confirm the expressions flow through at design time. But when I execute it from SSISDB, I get the error

Error: An error occurred with the following error message:

Failed to lock variable "Files successfully saved to
\\server.domain.com\TEST\Output Files AM"  for read access with error
0xC0010001 The variable cannot be found.  This occurs when an attempt
is made to retrieve a variable from the  Variables collection on a
container during execution of the package, and  the variable is not
there.  The variable name may have changed or the variable is not
being created.

I thought maybe it was a weird problem with escaping the backslashes, but I tried using a REPLACE() in the expression, no luck. I do use the underlying variable @[User::varSQLCSVOutputFolder] repeatedly, but I have precedent constraints set up, so there should be no overlap.... any other possibilities? It seems to be reading the CONTENT of my variable as the NAME of the variable.


Solution

  • Okay, this was a fun one. So, I had an expression defined for MessageSource, BUT, I had chosen MessageSourceType as Variable, not Direct Input. See below for posterity.

    Problem!

    Message Source is expression