SQL Server Agent 2005 作业运行但没有输出

发布于 2024-08-30 05:22:54 字数 569 浏览 7 评论 0原文

本质上,我有一个在 BIDS 中运行并作为独立包运行的作业,当它在 SQL Server 代理下运行时,它无法正确完成(但没有错误消息)。

工作步骤是:

1)删除表中的所有行;

2) 使用 For every 循环从 Excel 电子表格中填充表格;

3)清理桌子。

我已经尝试过这个MS页面(步骤1和2),没有看到任何需要从服务器端安全性开始改变。

还有 此页面的 SQLServerCentral.com,没有解决方案。

如何获取错误日志或修复?

请注意,我已从服务器故障重新发布此问题,因为它是不纯粹管理或编程的问题之一。

我已作为运行此任务的代理帐户登录,并且该作业独立运行,但抱怨 Excel 表为空?

Essentially I have a job which runs in BIDS and as as a stand lone package and while it runs under the SQL Server Agent it doesn't complete properly (no error messages though).

The job steps are:

1) Delete all rows from table;

2) Use For each loop to fill up table from Excel spreasheets;

3) Clean up table.

I've tried this MS page (steps 1 & 2), didn't see any need to start changing from Server side security.

Also SQLServerCentral.com for this page, no resolution.

How can I get error logging or a fix?

Note I've reposted this from Server Fault as it's one of those questions that's not pure admin or programming.

I have logged in as the proxy account I'm running this under, and the job runs stand alone but complains that the Excel tables are empty?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

吃→可爱长大的 2024-09-06 05:22:54

以下是我如何管理跟踪通过 SQL 代理作业调用的 SSIS 包的“返回状态”。如果幸运的话,其中一些可能适用于您的系统。

  • 作业调用存储过程
  • 过程构建 DTEXEC 调用(带有十几个或更多参数)
  • 过程调用 xp_cmdshell,并将调用作为参数 (@Command)
  • SSIS 包运行
  • “本地” SSIS 变量初始化为 1
  • 如果引发错误, SSIS“流”传递到将该局部变量设置为 0 的步骤
  • 在最后一步中,使用表达式将 SSIS 属性“ForceExecutionResult”设置为该局部变量(1 = 成功,0 = 失败)
  • SSIS 的完整形式调用存储返回值,如下所示:

    EXECUTE @ReturnValue = master.dbo.xp_cmdshell @Command

...然后它变得混乱,因为您可以获得从 SSIS 返回的大量值。我在执行 SSIS 步骤时将操作和活动记录在数据库表中,并查阅以尝试解决问题(这就是下面的 @Description 的来源)。这是相关的代码和注释:

--  Evaluate the DTEXEC return code
SET @Message = case
                 when @ReturnValue = 1 and @Description <> 'SSIS Package' then 'SSIS Package execution was stopped or interrupted before it completed'
                 when @ReturnValue in (0,1)   then ''  --  Package success or failure is logged within the package
                 when @ReturnValue = 3        then 'DTEXEC exit code 3, package interrupted'
                 when @ReturnValue in (4,5,6) then 'DTEXEC exit code ' + cast(@Returnvalue as varchar(10)) + ', package could not be run'
                 else 'DTEXEC exit code ' + isnull(cast(@Returnvalue as varchar(10)), '<NULL>') + ' is an unknown and unanticipated value'
               end
--  Oddball case: if cmd.exe process is killed, return value is 1, but process will continue anyway
--  and could finish 100% succesfully... and @ReturnValue will equal 1.  If you can figure out how,
--  write a check for this in here.

最后引用了“如果在 SSIS 运行时,某个管理员小丑杀死了 CMD 会话(例如,任务管理器),因为进程运行时间太长了”的情况。据我所知,我们从未发生过这种情况,但当我写这篇文章时,他们非常偏执,所以我必须调查一下……

Here's how I managed tracking "returned state" from an SSIS package called via a SQL Agent job. If we're lucky, some of this may apply to your system.

  • Job calls a stored procedure
  • Procedure builds a DTEXEC call (with a dozen or more parameters)
  • Procedure calls xp_cmdshell, with the call as a parameter (@Command)
  • SSIS package runs
  • "local" SSIS variable is initialized to 1
  • If an error is raised, SSIS "flow" passes to a step that sets that local variable to 0
  • In a final step, use Expressions to set SSIS property "ForceExecutionResult" to that local variable (1 = Success, 0 = Failure)
  • Full form of the SSIS call stores the returned value like so:

    EXECUTE @ReturnValue = master.dbo.xp_cmdshell @Command

...and then it gets messy, as you can get a host of values returned from SSIS . I logged actions and activity in a DB table while going through the SSIS steps and consult that to try to work things out (which is where @Description below comes from). Here's the relevant code and comments:

--  Evaluate the DTEXEC return code
SET @Message = case
                 when @ReturnValue = 1 and @Description <> 'SSIS Package' then 'SSIS Package execution was stopped or interrupted before it completed'
                 when @ReturnValue in (0,1)   then ''  --  Package success or failure is logged within the package
                 when @ReturnValue = 3        then 'DTEXEC exit code 3, package interrupted'
                 when @ReturnValue in (4,5,6) then 'DTEXEC exit code ' + cast(@Returnvalue as varchar(10)) + ', package could not be run'
                 else 'DTEXEC exit code ' + isnull(cast(@Returnvalue as varchar(10)), '<NULL>') + ' is an unknown and unanticipated value'
               end
--  Oddball case: if cmd.exe process is killed, return value is 1, but process will continue anyway
--  and could finish 100% succesfully... and @ReturnValue will equal 1.  If you can figure out how,
--  write a check for this in here.

That last references the "what if, while SSIS is running, some admin joker kills the CMD session (from, say, taskmanager) because the process is running too long" situation. We've never had it happen--that I know of--but they were uber-paranoid when I was writing this so I had to look into it...

世界等同你 2024-09-06 05:22:54

为什么不使用 SSIS 内置的日志记录?我们将日志发送到数据库表,然后以更用户友好的格式将它们解析到另一个表,并且可以看到运行的每个包的每一步。以及每一个错误。

Why not use logging built into SSIS? We send our logs toa database table and then parse them out to another table in amore user friendly format and can see every step of everypackage that was run. And every error.

岁月如刀 2024-09-06 05:22:54

我最终解决了这个问题,感谢您的建议。

基本上,我使用正在运行的代理用户帐户登录 Windows,并开始看到如下错误:
“For Each 文件枚举器为空”

我复制了项目文件并开始测试,结果发现我仍然在 For Each 循环框的属性中留下了一个文件路径 (N:/),尽管我更改了连接属性。一旦你有了可以处理的错误条件,事情就会变得更容易。我还必须重新创建变量映射。

难怪人们会重新创建整个包。

现在已修复并可以使用!

I did fix this eventually, thanks for the suggestions.

Basically I logged into Windows with the proxy user account I was running and started to see errors like:
"The For each file enumerator is empty"

I copied the project files across and started testing, it turned out that I'd still left a file path (N:/) in the properties of the For Each loop box, although I'd changed the connection properties. Easier once you've got error conditions to work with. I also had to recreate the variable mapping.

No wonder people just recreate the whole package.

Now fixed and working!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文