Failed to lock variable for read/write access

  • HI, I have a package with a script task that writes to a variable. The variable is specified as Read/Write in the script properties. In debug mode all is fine however when running the package under the SQL Agent I get the Failed to lock variable for read/write access.

    It also runs OK if I run the package manually from the Integration Services DB.

    Any ideas?

    Thanks

    Allen

  • Strange. You could try removing the variable from the Read/Write section and instead use the VariableDispenser method to retrieve/set the variable.

    The absence of evidence is not evidence of absence.
    Martin Rees

    You can lead a horse to water, but a pencil must be lead.
    Stan Laurel

  • Hi Phil,

    Thanks! That sorted it. I found one of your code snippets on this site that used the VariableDispenser to read a row and it was simple to switch it round to write (I hadn't used it before).

    One thing I did notice is that after re-building the package in BIDS I had to re-import the package into the Integration Services DB -> Stored Packages -> File System. That surprised me, can you enlighten me? I use SSIS frequently but only at quite a basic level.

    Cheers

    Allen

    PS - like the avatar!

  • Thank you Allen - I was looking particularly healthy and radiant the day that one was taken :w00t:

    When you modify a package in BIDS, you are probably updating a version of the DTSX file which is different from the Stored Packages -> File System version, which explains the need for importing. Not a part of the system I'm very familiar with, I just like doing the dev 🙂

    The absence of evidence is not evidence of absence.
    Martin Rees

    You can lead a horse to water, but a pencil must be lead.
    Stan Laurel

  • Hmm - makes sense.

    Thanks Phil

Viewing 5 posts - 1 through 4 (of 4 total)

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