如何计算在SSIS中插入或更新的行数

how to count number of rows inserted or updated in SSIS

我有一个 ssis 项目用于从 table 或 excel sheet 中插入大量行 table.i 想知道有多少行inserted in table while my project is 运行 我需要使用哪个功能。

最好的方法是使用 ROW COUNT :

首先在你的包中创建一个变量,在我的例子中,我将变量命名为 ROWNUM

其次在数据流中添加组件 ROW COUNT 如下图所示:

双击 Row count component 并在 Component properties tab 中转到 Variable Name 和 select 您的变量。

第三次添加脚本任务如下图

双击 Script task component,您将看到 ReadonlyVariable 和 select 您的变量,然后单击 Edit script,您将看到 Main method 和编写如下行代码:

 public void Main()
        {
            // TODO: Add your code here
            Dts.TaskResult = (int)ScriptResults.Success;
            MessageBox.Show("Rows inserts are "+Dts.Variables["User::ROWNUM"].Value.ToString()+" rows ");
        }