SSIS连接表达式问题

发布于 2024-12-04 14:54:28 字数 198 浏览 0 评论 0原文

我尝试在 SSIS 中使用子包的表达式,但它总是出错,指出找不到 dtsx 文件。我已经复制了资源管理器的路径,它似乎是正确的。

该错误还指出表达式无法写入该属性。我的代码如下。

中的变量

@[User::vRoot] + "\Employees.dtsx" 其中 @[User::vRoot] 是存储在 SQL Any Ideas

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

阳光①夏 2024-12-11 14:54:28

尝试使用额外的反斜杠来转义表达式中的反斜杠。

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

在这种情况下,我需要连接文件夹和文件名,我总是这样做。我通常创建两个名为 FolderPathFileName 的变量。假设FolderPath包含C:\temp\确保它以反斜杠结尾)并且FileName包含员工.dtsx。

我将创建第三个名为 FilePath 的变量,并将该变量的 EvaluateAsExpression 属性设置为 true。我将在此变量中设置以下表达式,以便它动态计算该值。

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

希望有帮助。

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.

杯别 2024-12-11 14:54:28

反斜杠在这里是一个转义字符,所以如果你想表示一个字面上的反斜杠,那就是“\\”。

我还建议,作为一般规则,不要在字符串连接中硬编码反斜杠,而是使用此方法来考虑第一个变量中潜在的尾部反斜杠:

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

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"

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文