如何修改SSIS中的变量? [英] How to modify the variable in SSIS?
问题描述
我有一个简单的字符串变量,其值如下:C:\Test.txt".现在我想编辑变量以指向不同的文件.我找不到办法做到这一点.我可以更改名称、数据类型,但不能更改值本身!我需要删除变量并创建新变量吗?
I have a simple String variable with the following value: "C:\Test.txt". Now I would like to edit the variable to point to a different file. I cannot find a way to do that. I can change the Name, Data Type, but not the value itself! Do I need to delete the variable and create the new one?
更新:该问题是由ReadOnly"属性设置为True"引起的.对于典型场景,请参阅下面已接受的答案.
Update: The problem was caused by "ReadOnly" property set to "True". For typical scenarios, see the accepted answer below.
推荐答案
如果您想在设计器中更改它,只需右键单击可用空间和 --> 变量.
If you want to change it in designer just right click on free space and --> Variables.
但是如果您想在运行时更改它,我建议您:
But if you want to change it at runtime I suggest you to:
- 创建脚本任务
- 选择语言
- 将您的变量添加到 ReadWriteVariables.
- 编辑脚本.
例如在 VB 中:
- create script task
- choose language
- add your variable to ReadWriteVariables.
- Edit script.
For example in VB:
Dts.Variables("myVariable").Value = @"C:\Test2.txt";
Dts.TaskResult = ScriptResults.Success
这篇关于如何修改SSIS中的变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!