Richard Banks
Richard Banks

Reputation: 2983

SSIS connection expression problem

Im trying to use an expression to a sub package in SSIS however it always errors out stating that it cannot find the dtsx file. Ive copied the path to explorer and it seems to be correct.

The error also states that expression cannot be written to the property. My code is below.

@[User::vRoot] + "\Employees.dtsx" with @[User::vRoot] being a variable stored in SQL

Any Ideas

Upvotes: 1

Views: 2056

Answers (2)

Giuseppe Genga
Giuseppe Genga

Reputation: 1

Backslash is an escape character here, so if you want to represent a literal backslash, it's "\\".

I also suggest, as a general rule, instead of hardcoding a backslash in the string concatenation, to use this method to consider potential trailing backslashes in the first variable:

@[User::vRoot] + (RIGHT(@[User::vRoot], 1) == "\\" ? "" : "\\") + "Employees.dtsx"

Upvotes: 0

user756519
user756519

Reputation:

Try to escape the backslash in the expression using an additional backslash.

@[User::vRoot] + "\\Employees.dtsx"

In such a scenario where I need to concatenate folder and file name, I always do it this way. I usually create two variables named FolderPath and FileName. Let's assume FolderPath contains C:\temp\ (make sure it ends with a back slash) and FileName contains Employees.dtsx.

I will create a third variable named FilePath and will set the EvaluateAsExpression property of this variable to true. I will set the following expression in this variable so it dynamically evaluates the value.

@[User::FolderPath] + @[User::FileName]

Hope that helps.

Upvotes: 2

Related Questions