Cannot delete filename. There has been a sharing violation.

  • StefanJ

    SSCarpal Tunnel

    Points: 4713

    I get the following message after a file has been locked by a long running job (which fired a DTS package) which I had to stop.

    "Cannot delete filename. There has been a sharing violation.

    The source or destination file may be in use."

    Other than reboot the server, is there any other way of deleting this file?

  • barsuk

    SSChampion

    Points: 12179

    just a guess. Do you know of any process which might be using this file. Then try to terminate that process and delete the file.

  • StefanJ

    SSCarpal Tunnel

    Points: 4713

    "Do you know of any process which might be using this file"

    Yes I have worked out exactly which process caused the problem.

    There is a job running which runs a DTS Package. Within this package I use the file object to copy an excel template and then use CreateObject("Excel.Application") to open the copied Excel workbook and manipulate it.

    During this process, I reckon Excel asked for user response which as it is invisible caused the job to go into an indefinite wait. I stopped the job.

    I have identified the reason why Excel asked for user response and will eliminate the cause, however this could happen again and having to reboot the server is not a very satisfactory solution.

    By the way I connect to the Server using Terminal Services.

  • StefanJ

    SSCarpal Tunnel

    Points: 4713

    It happened again, this time I pressed CTRL SHIFT ESC to open the Task Manager and found and killed the hidden Excel process.

  • StefanJ

    SSCarpal Tunnel

    Points: 4713

    It happened again, this time I pressed CTRL SHIFT ESC to open the Task Manager and found and killed the hidden Excel process.

  • This was removed by the editor as SPAM

  • This was removed by the editor as SPAM

  • This was removed by the editor as SPAM

  • This was removed by the editor as SPAM

  • Jeff Moden

    SSC Guru

    Points: 996832

    Post deleted.  It's no longer needed.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.
    "Change is inevitable... change for the better is not".
    "If "pre-optimization" is the root of all evil, then what does the resulting no optimization lead to?"

    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • This was removed by the editor as SPAM

Viewing 11 posts - 1 through 11 (of 11 total)

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