Need to pass a string with spaces to SSIS package

  • As you see below, I am using a stored procedure that takes a @FilePath parameter and then passes this parameter to the package. Thing is, the file path contains spaces and this messes up the call to dtexec.  Is there a way to 'escape' the spaces in the file path so dtexec recognises them as part of the string?

     

    Create

    PROCEDURE [dbo].[usp_Call_Extract] (@FilePath as varchar(max))

    AS

    BEGIN

    DECLARE @returncode int

    Declare @commandstring varchar(500)

    set @commandstring='dtexec /f "d:\ExtractPackages\Extract.dtsx" /set \package.variables[GetFilePath].Value;"' + @FilePath + '"'

    --the path below will need to be changed to the

    --location of the SSIS package when the BAL extract is deployed

    EXEC @returncode = xp_cmdshell @commandstring

     

    END

  • Hi Mike,

    I simulated your problem, but it works fine for me... Even with filenames with spaces in them...

    Gogula

  • Hummm.....

    Maybe it is not the spaces that are the problem then. I'll see if I can find anything else that may be the problem.

    Thanks

    -Mikel

  • No, it has to the be spaces that are the problem.

    Here is my exec command:

    USE

    [Servicer_meextract_bal]

    GO

    DECLARE

    @return_value int

    EXEC

    @return_value = [dbo].[usp_Call_Bal_Extract_SSIS_FilePath]

    @FilePath

    ='\\snara\SNAP\apps\Extract\Test Reports and Backups\Extract Files'

    SELECT

    'Return Value' = @return_value

    GO

     

    The error I get is "Option "Reports" is not valid." If I take the spaces out of the file path, the package runs (though I get an error because the path does not exist.) I've tried running it with some spaces removed but it always tells me that the word directly after the first space in the string "is not valid".

    Anyone seen this before?

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

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