xp_cmdshell move error

  • Hello,

    I want to execute the following bit in a stored procedure (which is called through a cursor) to move the files to another location.

    EXEC('xp_cmdshell ''move "d:\Prospects\' + @FileName2 + '" "d:\ValidatedFolder"''').

    The output I am getting is 'The process cannot access the file because it is being used by another process'.and is not moving any files I want to move to the desired location.

    Any help is highly appreciated.

    Thanks in advance

  • did your cursor just create the file prior to moving it? it's quite possible that the command to create the file was issued, and the disk sub system is still actually writing the file to disk by the time the next command to move the file is issued.

    if you just created it, and are already moving it, why not create it in the final location in the first place? is another process doing something to the file between creation and moving?

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • You can find out which process is using that file. An example explained here[/url]

    Pradeep Adiga
    Blog: sqldbadiaries.com
    Twitter: @pradeepadiga

Viewing 3 posts - 1 through 2 (of 2 total)

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