How to change a variable in SSIS?

I have a simple String variable with the following value: "C: \ Test.txt". Now I would like to edit the variable to point to another file. I cannot find a way to do this. I can change the name, data type, but not the value itself! Do I need to delete a variable and create a new one?

Update: The problem arose due to the property "ReadOnly" set to "True". For typical scenarios, see the accepted answer below.

+5
source share
2 answers

If you want to change it in the designer, just right-click on the free space and → Variables.

But if you want to change it at runtime, I suggest you:

  • script
  • ReadWriteVariables.
  • script.
  • , VB:

    Dts.Variables( "myVariable" ). = @ "C:\Test2.txt";

    Dts.TaskResult = ScriptResults.Success

+8

@Yuck @devarc, Variable. Design-time - , , . C:\Test.txt . , , C:\Test.txt,

Currentfile

, , . CurrentFile C:\Test.txt

, , , , BIDS, "" . , "", .

enter image description here

" " - (C:\Test.txt), "" (C:\Test2.txt)

SSIS . , , . , ( .

/SET

(dtexec.exe), (dtexecUI.exe) SQL SQL Server SET. , C:\Test2.txt

dtexec /file C:\Generated.dtsx /set \Package.Variables[User::CurrentFile].Properties[Value];"C:\Test2.txt"

SSIS . , , , , . , : SET , "" .

SSIS , , . , , .

A Script - , SSIS, .

Foreach Loop SQL- - , .

- SSIS. "" SSIS . , .

, 3 RootFolder, FileName ComputedCurrentFile C: \, File2.txt . "" ComputedCurrentFile EvaluateAsExpression False True @[User::RootFolder]+ "\\" +@[User::FileName]. , . , , . , , , , , .

, . , , .

+15

All Articles