Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ssis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Transactions SSIS包能否在现有外部事务中登记?_Transactions_Ssis_Msdtc - Fatal编程技术网

Transactions SSIS包能否在现有外部事务中登记?

Transactions SSIS包能否在现有外部事务中登记?,transactions,ssis,msdtc,Transactions,Ssis,Msdtc,我以前问过一个模糊不清的类似问题(尽管具体是从xp_cmdshell运行包)。我对此事的最后一点评论是,如果我想确保SSIS包在事务中登记,我的选项是什么 那么,有没有办法执行SSIS包并让它参与到已经存在的事务中 如果出于测试目的,我们希望: 运行包以加载数据 对加载的数据运行测试 将所有加载的数据回滚 谢谢, 斯图尔特。互联网对这个问题的解决方案非常沉默。我也有同样的问题,到处寻找解决办法。SSIS对错误操作时生成的错误消息(未记录的错误代码)也没有帮助。答案可能有点晚,但希望它能帮助人

我以前问过一个模糊不清的类似问题(尽管具体是从xp_cmdshell运行包)。我对此事的最后一点评论是,如果我想确保SSIS包在事务中登记,我的选项是什么

那么,有没有办法执行SSIS包并让它参与到已经存在的事务中

如果出于测试目的,我们希望:

  • 运行包以加载数据
  • 对加载的数据运行测试
  • 将所有加载的数据回滚
谢谢,
斯图尔特。

互联网对这个问题的解决方案非常沉默。我也有同样的问题,到处寻找解决办法。SSIS对错误操作时生成的错误消息(未记录的错误代码)也没有帮助。答案可能有点晚,但希望它能帮助人们避免浪费时间。这就是我的工作

例如,在单元测试中,将整个流程包装在TransactionScope中:

using (TransactionScope scope = new TransactionScope(TransactionScopeOption.RequiresNew,new TransactionOptions(){IsolationLevel =IsolationLevel.ReadCommitted}))
        { 
          Application app = new Application();
          Package package = app.LoadPackage(packageFileName, null);

          // Can set package settings for test
          package.TransactionOption = DTSTransactionOption.Required;
          package.IsolationLevel = IsolationLevel.ReadCommitted;

          // Use this overload for execute
          DTSExecResult result = package.Execute(null, null, null, null, TransactionInterop.GetDtcTransaction(Transaction.Current));

          // Test results here inside the scope
}
当然,如果您想将数据添加到数据库中,那么您可以重新排列它,然后通过SSI提取数据,然后在测试数据后回滚