Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2005
    Posts
    58

    Unanswered: Path spaces using xp_cmdshelll

    I know this is probably a DOS question but does anyone know how the following would work without taking out the spaces in the folder "Audit Tax Planning\" (works fine in paths without spaces)?

    Declare @ren varchar(255)
    Declare @path varchar(100)

    Set @path = '\\main\WGDATA\Accounting\Audit Tax Planning\' --G:\Accounting\Audit Tax Planning\05BE

    IF EXISTS(SELECT id FROM tempdb..sysobjects WHERE id = object_ID('tempdb..#Tax_File'))
    DROP TABLE #Tax_File

    CREATE TABLE [#Tax_File](
    [File_Name] varchar(50),
    )


    Set @ren = 'dir /B ' + @path + 'test.txt'

    Insert into #Tax_File ([File_Name])
    EXEC master..xp_cmdshell @ren


    If not exists(select [File_Name]
    from #Tax_File
    where right([File_Name],4) = '.txt')
    begin
    RAISERROR ('File does not exist.', 16, 1)
    Return
    end

    select * from #Tax_File

  2. #2
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  3. #3
    Join Date
    Oct 2005
    Posts
    58
    Yup, the quotes inside work, thank you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •