这实际上非常简单 -在 Script 组件的类中使用成员变量(也称为field ):ScriptMain
/* Microsoft SQL Server Integration Services Script Component
* Write scripts using Microsoft Visual C# 2008.
* ScriptMain is the entry point class of the script.*/
using System;
using System.Data;
using Microsoft.SqlServer.Dts.Pipeline.Wrapper;
using Microsoft.SqlServer.Dts.Runtime.Wrapper;
[Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute]
public class ScriptMain : UserComponent
{
private int _myVariable = 0;
public override void Input0_ProcessInputRow(Input0Buffer Row)
{
Row.SomeValue = _myVariable;
_myVariable = Row.SomeOtherValue;
}
}