Showing posts with label dtexec. Show all posts
Showing posts with label dtexec. Show all posts

Monday, March 26, 2012

Passing GUID into dtexec, invalid cast to a string variable. Solution?

I am getting an invalid cast specification when I call dtexec and try to /SET a user variable within the package that is defined as a string data type. Is there any solution to this? I have tried passing the GUID with {} w/o {} w/ '' w/ "" etc.. many variations... and still get an invalid cast specification. Is there a data type that I need to set the User variable to besides String? The User Variable is used to Select records from a SQL data source where the GUID is stored. I do not have an option of GUID data type for a User Variable.

Thanks for any help! Aaron B.

What does your SET look like, this works fine for me. I just set it, and check the value in a Script Task, just to ensure the value is being passed in OK.

/SET "\Package.Variables[StringVariable].Value";"{2B7045E0-F3D2-478a-BCC3-0E73858C59A8}"

|||

Thanks for your help i am using another field for the subquery which is not GUID and its working fine. Thanks for your help.

Friday, March 9, 2012

pass variable with a space

Hi,

I am passing a filename to a command in sql.

The problem is that it gives an error if the @.FullFilePath has a space in it.

set @.cmd = 'dtexec /f ' + @.FullPackagePath + ' /set \Package.Variables[User::FileName].Properties[Value];' + @.FullFilePath + '"'

print @.cmd

Thanks

As with everything, use quotes... ""|||

This is the stored procedure which passes the filename

uspCEMTradeExecutePackage 'd:\sysappl\CEM\SSIS\Imports\Trades\csa.dtsx', 'CSA data.csv'

Notice the filename, i.e. 'CSA data.csv'

It has a space in it.

Do you mean the call to the stored procedure should be:

uspCEMTradeExecutePackage 'd:\sysappl\CEM\SSIS\Imports\Trades\csa.dtsx', '"CSA data.csv"'

this does not seem correct.

Thanks

|||

That is correct, you need the single quotes outside of the double quotes. When you call DTEXEC with a variable or path that has spaces in it, it has to be wrapped in double quotes.

Or you could change the command line to include the double quotes:

Code Snippet

set @.cmd = 'dtexec /f ' + @.FullPackagePath + ' /set \Package.Variables[User::FileName].Properties[Value];"' + @.FullFilePath + '"'