XP_CMDSHELL

  • Hi All,

    Please help me in this.

    I am trying to read file names in my local drive using XP_CMDSHELL.

    Below is the query i am using to read the file name.

    SELECT @ServerName = 'MyServer'

    SELECT @SourceFolder = 'L:\SQL2008_Backup\Full Backup

    SELECT @Cmd = 'master..xp_cmdshell ''DIR ' + @SourceFolder + ' /B'''

    By executing this i m getting the below error.

    -----------------

    File Not Found

    -----------------

    I feels its because of space in the folder name [Full Backup].

    please provide me the solution to reslove this issue.

    Thanks in advance.

    Regards,

    Vijay

  • Got it..

    Below query works.:-)

    SELECT @SourceFolder = '"L:\SQL2008_Backup\Full Backup"'

  • using CLR procedure, much more secure,robust free and extensible solution here

    http://sql-library.com/?p=186

    www.sql-library.com[/url]

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

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