A white space in a URL

  • Hi, All

    hopefully it'll be an easy one for you.

    Scenario: every time a certain record gets inserted into a table, I need to create a folder somewhere on a remote Win 2003 machine. I chose to use sproc xp_cmdshell for that. I'm running these two lines:

    1. EXEC master.dbo.xp_cmdshell 'md \\l5600b\share\sergei\test_del\test'

    2. EXEC master.dbo.xp_cmdshell 'md \\l5600b\share\sergei\test del\test'

    Line 1 executes OK, creating a subfolder 'test'

    Line 2 does not do what I want; the folder 'test' is not created, and the reason is, I suspect, the white space in the parent folder's name 'test del'.

    Q: does anyone know a workaround for that? I tried using %20 instead of the white space, it did not help.

    I cannot change the names of the target parent folders where my subfolders need to be created. They are on production server.

    Any advice would be much appreciated,

    Thanks,

    Sergei Z

  • Just a guess...

    EXEC master.dbo.xp_cmdshell 'md "\\l5600b\share\sergei\test del\test"'

    Ryan Randall

    Solutions are easy. Understanding the problem, now, that's the hard part.

  • Ryan,

    your guess was correct. Thank you for quick answer. I'm not even going to pretend it was a mental block for me ;=) simply did not think about double quotes inside single quotes.

    this works to create a windows folder:

    declare @myParam nvarchar (1024)

    declare @mySQL nvarchar (1024)

    set @myParam = ''''+ 'md "\\l5600b\share\sergei\test del\test11"' +''''

    print @myParam

    set @mySQL = 'master.dbo.xp_cmdshell ' + @myParam

    print @mySQL

    exec (@mySQL)

    Cheers,

    Sergei Z

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

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