无法在SQL Job中执行SSIS包

时间:2018-09-01 08:20:23

标签: c# sql-server ssis ssms

我有一个仅包含2个步骤的简单SSIS程序包。步骤1是一个脚本任务,它将返回特定文件夹中最后创建的文件的创建日期。第二步,它将步骤1的数据保存到数据库中。这是C#中第1步的完整代码。

string vDir = Dts.Variables["UnitDirectory"].Value.ToString();
string vDBName = Dts.Variables["DatabaseName"].Value.ToString();

var directory = new DirectoryInfo(vDir);
var myFile = directory.GetFiles(vDBName + "*").OrderByDescending(f => f.LastWriteTime).First();

DateTime creation = File.GetCreationTime(vDir + myFile);

Dts.Variables["CreatedDate"].Value = creation;
Dts.TaskResult = (int)ScriptResults.Success;

在这种情况下,我将UnitDirectory变量与网络共享目录一起传递。

\\192.168.0.2\Database Backup\

问题是,我可以从SQL Server Management Studio的Integration Service目录和Visual Studio中执行此程序包。但是,当我将其作为SQL Job执行时,它只是在步骤1中出错并给出了不清楚的消息。

Script Task:Error: Exception has been thrown by the target of an invocation.

我使用域管理员凭据运行SQL Job,该凭据具有对网络共享目录的登录访问权限。当我在新安装的SQL Server 2014中运行时,就会开始出现此问题。以前,此程序包已在我的旧SQL Server中正常运行。

您能给我解决方法吗?我需要基于您的经验的解决方案。预先感谢。

0 个答案:

没有答案