1

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.

olinox14
  • 6,177
  • 2
  • 22
  • 39
Quicksilver
  • 295
  • 4
  • 16
  • 1
    I'm not sure what's going on here but if you are just copying files around I suggest Robocopy or Powershell.... but I understand that design decisions are made for various reasons. If you want to debug what you have I suggest you strip it back to basics until you find the issue. I also have a current weird issue with SSIS variables that I have spent a lot of time on that I can't work out. Conclusion - SSIS variables are not practical to debug. – Nick.Mc Jun 18 '19 at 00:10

1 Answers1

1

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

Quicksilver
  • 295
  • 4
  • 16