SISS 变量 -

发布于 2024-12-07 10:08:41 字数 167 浏览 1 评论 0原文

我在包级别创建了用户定义的 SSIS 变量。

示例:这里是变量

v1 = 10

v2 = 20

v3

结果应该是 V3 = V1 +V2 我应该在控制流中的哪里给出这个表达式以及我会得到结果

请帮助

谢谢

I have created user defined SSIS variables at the package level.

Example: Here are the varibales

v1 = 10

v2 = 20

v3

The result should be V3 = V1 +V2 Where should i give this expression in the control flow and will i get the result

Please help

Thanks

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

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

发布评论

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

评论(2

榕城若虚 2024-12-14 10:08:41

我是否遗漏了某些内容,或者是否有原因 表达式 不会够了吗?

给定如上所述定义的变量

Variables window

在变量 v3 上将“Evaluate as Expression”设置为 True,对于表达式,使用@[User::v1] + @[User::v2] (或单击省略号并使用所见即所得编辑器构建表达式)

属性窗口

如果您注意到 v3 的粉红色角,那是因为我运行了一个名为 BIDSHelper 它可以帮助您完成 SSIS 开发任务,但绝不会影响我的解决方案的工作。

Am I missing something or is there a reason an expression won't suffice?

Given variables defined as described above

Variables window

Set "Evaluate as Expression" to True on the variable v3 and for the Expression, use @[User::v1] + @[User::v2] (or click the ellipses and build the expression with the WYSIWYG editor)

Properties window

If you notice the pink corner of v3, that is due to me running an add-in called BIDSHelper which can assist in your SSIS development tasks but in no way affects the workings of my solution.

金兰素衣 2024-12-14 10:08:41

您可以在脚本组件中操作变量。如果您使用的是 SQL-Server 2005,则可以使用 VB.Net;如果您使用的是 2008,则可以选择 VB.Net 或 C#.net。

以下是我用来获取变量(在我的例子中为字符串)、操作它们并将它们发送回变量存储区域的一些(VB.net)代码示例:

Dim logFilename As String
Dim logFilePath As String

' create filename
logFilePath = Dts.Variables("LogFilePath").Value.ToString()
curDate = Now().ToString("yyyyMMdd")
logFilename = "test-" & curDate & ".Log"
Dts.Variables("LogFileName").Value = logFilename

对您的数字执行相同的操作,在内部脚本组件(我对 VB 有点生疏)

Dim v1 as Int
Dim v2 as Int
Dim v3 as Int

// get your variables from the package 
v1 = Dts.Variables("v1").Value
v2 = Dts.Varuables("V2").Value
v3 = v1 + v2
// set your result back to the package
Dts.Variables ("v3").Value = v3

You can manipulate variables within a Script Component. If you're using SQL-Server 2005 you get to use VB.Net, if you're using 2008, you have the choice of that or C#.net.

Here are some (VB.net) examples of code I've used to get variables (strings in my case), manipulate them, and send them back to the variable storage area:

Dim logFilename As String
Dim logFilePath As String

' create filename
logFilePath = Dts.Variables("LogFilePath").Value.ToString()
curDate = Now().ToString("yyyyMMdd")
logFilename = "test-" & curDate & ".Log"
Dts.Variables("LogFileName").Value = logFilename

To do the same with your numbers, in the guts of the Script Component (I'm a bit rusty with VB)

Dim v1 as Int
Dim v2 as Int
Dim v3 as Int

// get your variables from the package 
v1 = Dts.Variables("v1").Value
v2 = Dts.Varuables("V2").Value
v3 = v1 + v2
// set your result back to the package
Dts.Variables ("v3").Value = v3
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文