none
Variable is used as a source or destination and is empty. RRS feed

  • Question

  • I am working in SQL Server 2005.  I've created an SSIS package that's using a For Each File Loop and passing a variable for the filename.  I was able to add a data flow task inside of the loop that uses the variable name and it works fine.  I'm trying to add an additional task into the loop so that when the data flow is complete, the file is moved to a different folder.  I've added a File System task and set the operation to Move File.  I set the IsSourcePathVariable to true and I set the Source Variable to my file variable created in the loop.   I set the  I am getting the error "Variable 'VarFileName' is used as a source or destination and is empty."  VarFileName is the name of my variable created in the For Loop.  Is there another step I am missing? 

    I tried to search on this error, but the search no longer seems to be working out here.  So I apologize if this has already been answered.  Thanks!!

    Wednesday, January 28, 2009 3:09 PM

Answers

  • I think that your problem is that in design time, when you're not executing the package, your file name variable is empty.  It hasn't been set by the For Each Loop - because it's not running yet.  Since it's empty, SSIS can't ensure that the Move operation will succeed.  Your response is "of course it can't!" which is entirely correct.  You need to tell SSIS that it shouldn't worry about checking that Task before it actually tries to run it, because you know it will work properly.  To do that, set the DelayValidation property to True on the File System Task.


    Todd McDermid's Blog
    • Marked as answer by SKK_ Wednesday, January 28, 2009 6:01 PM
    Wednesday, January 28, 2009 5:43 PM
    Moderator

All replies

  • I think that your problem is that in design time, when you're not executing the package, your file name variable is empty.  It hasn't been set by the For Each Loop - because it's not running yet.  Since it's empty, SSIS can't ensure that the Move operation will succeed.  Your response is "of course it can't!" which is entirely correct.  You need to tell SSIS that it shouldn't worry about checking that Task before it actually tries to run it, because you know it will work properly.  To do that, set the DelayValidation property to True on the File System Task.


    Todd McDermid's Blog
    • Marked as answer by SKK_ Wednesday, January 28, 2009 6:01 PM
    Wednesday, January 28, 2009 5:43 PM
    Moderator
  • That worked!!  Thanks for the great explanation along with the answer!  I really appreciate it.
    Wednesday, January 28, 2009 6:00 PM
  • Click on that variable and press F4, that will take you to properties.

    Set EvaluteAsExpression=True

    Wednesday, March 29, 2017 4:25 AM
  • One day I hope to remember the DelayValidation switch before running off to stackoverflow.
    Friday, August 18, 2017 2:05 PM