在作业SQL Server中运行时SSIS失败

时间:2018-12-17 03:50:27

标签: sql-server ssis sql-server-2012

我有一个SSIS包,当我从Visual Studio中执行它时,它运行平稳,但是当我通过SQL Server Job Task运行它时,它总是无法运行并引发此错误:

  

消息以用户身份执行:隐藏 \ 隐藏。 Microsoft(R)SQL Server执行软件包实用程序版本11.0.6020.0(用于64位版权(C))   微软公司。版权所有。开始于:10:23:40 AM   错误:2018-12-17 10:23:40.63代码:0x00000001源:更新   报告说明:目标服务器已抛出异常   调用。结束错误DTExec:返回包执行   DTSER_FAILURE(1)。开始时间:10:23:40 AM完成时间:10:23:40 AM   经过的时间:0.594秒。程序包执行失败。步骤   失败。

我不知道确切的问题,其他作业正常工作,我想这可能与以下事实有关:我们刚刚迁移到新服务器,而其他作业是从旧服务器镜像的旧作业

此SSIS程序包包含修改Excel文件的脚本任务。这对我公司来说是正常的,因为我们运行许多自动化任务,直到现在所有这些任务都一直正常工作。

有解决这个问题的主意吗?

1 个答案:

答案 0 :(得分:0)

最终我找到了答案,

我的脚本任务中包含此脚本

Declare Function EndTask Lib "user32.dll" (ByVal hWnd As IntPtr) As Integer
Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" _
       (ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
Declare Function GetWindowThreadProcessId Lib "user32.dll" _
       (ByVal hWnd As IntPtr, ByRef lpdwProcessId As Integer) As Integer
Declare Function SetLastError Lib "kernel32.dll" (ByVal dwErrCode As Integer) As IntPtr
Public Sub EnsureProcessKilled(ByVal MainWindowHandle As IntPtr, ByVal Caption As String)
    SetLastError(0)
    ' for Excel versions <10, this won't be set yet
    If IntPtr.Equals(MainWindowHandle, IntPtr.Zero) Then
        MainWindowHandle = FindWindow(Nothing, Caption)
    End If
    If IntPtr.Equals(MainWindowHandle, IntPtr.Zero) Then
        Exit Sub ' at this point, presume the window has been closed.
    End If
    Dim iRes, iProcID As Integer
    iRes = GetWindowThreadProcessId(MainWindowHandle, iProcID)
    If iProcID = 0 Then ' can’t get Process ID
        If EndTask(MainWindowHandle) <> 0 Then Exit Sub ' success
        Throw New ApplicationException("Failed to close.")
    End If
    Dim proc As System.Diagnostics.Process
    proc = System.Diagnostics.Process.GetProcessById(iProcID)
    proc.CloseMainWindow()
    proc.Refresh()
    If proc.HasExited Then Exit Sub
    proc.Kill()
End Sub

在这台新服务器中,我无权运行此脚本来终止进程,这就是为什么该作业总是为0x00000001错误抛出失败消息的原因,

感谢大家尝试回答这个问题