Cari Blog Ini

12 Juni 2012

“The system cannot find the file specified” When Using xp_cmdshell

Apply To :
Microsoft SQL Server 2000

Error Messages :

The system cannot find the file specified. When using xp_cmdshell.








-----code:start

Declare @CopyCommand as varchar(200)

select @CopyCommand='copy C:\Backup Test\DB_Test120612_1459.DAT C:\'

EXEC master..xp_cmdshell @CopyCommand

-----code:end


Results Messages:
output
----------------------------------------------------------------------
The system cannot find the file specified.
NULL

(2 row(s) affected)




Solution:

•    Check the “Source Path” is could accessible for the login account.
•    Make sure for the spelling name of "Source Path",
Example: "C:\Backup Test" - It's mean character "space" or " ", could not supported.
There's should be "C:\backupTest".





After Fix the “Source Path”:

-----code:start

Declare @CopyCommand as varchar(200)

select @CopyCommand='copy C:\backupTest\DB_Test120612_1459.DAT C:\'

EXEC master..xp_cmdshell @CopyCommand

-----code:end


Results Messages:
output
-----------------------------------------------------------------------------
        1 file(s) copied.
NULL

(2 row(s) affected)