XP_Cmdshell

  • Hi,

    While executing command xp_cmdshell "dir D:\Program Files\Microsoft SQL Server\MSSQL$new\BACKUP\" from the query analyzer window of the sql server 2000 which has the latest service pack throwing the below error message "The system cannot find the file specified."

    What would be the root cause of this issue.But i can able to open this path from the windows run command.

    Thanks in Advance.

  • This is due to the length of the string that you are passing.

    Use quotes like I have used below:

    This will work

    xp_cmdshell 'dir C:\"Program Files"'

    This will NOT work

    xp_cmdshell 'dir C:\Program Files'

    Amit Pandey

    SQL Server DBA

  • Amit Pandey DeBugSQL (7/14/2010)


    This is due to the length of the string that you are passing.

    Use quotes like I have used below:

    This will work

    xp_cmdshell 'dir C:\"Program Files"'

    This will NOT work

    xp_cmdshell 'dir C:\Program Files'

    Amit Pandey

    SQL Server DBA

    Thanks its working for me.

    EXEC master..xp_cmdshell 'dir d:\"Program Files\Microsoft SQL Server\MSSQL$new\BACKUP\"'

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

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