如何使用循环条件或任何其他逻辑填充会话表 [英] How to populate the session table using Loop condition or any other logic

查看:79
本文介绍了如何使用循环条件或任何其他逻辑填充会话表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个预定的工作,它将通过SSIS包执行程序,此程序将执行

I have a scheduled job where it will execute the Procedure through SSIS Package where this procedure will execute

EXEC USP_Load_Tables(Tbl_Name)

执行此会话表时将填充 如下表所示。

while executing this session table will populate  like the given below table.

如果包使用检查点失败,我们可以使用检查点从那里启动包。由于某些原因,该包没有实现。

If the package fails by using check point we can start the package from there by using check points . That one hasn't implemented due to some reasons.

因此,每当Package失败时,我们都需要手动执行这些表。

So manually we need to execute the tables every time when Package fails .

EXEC USP_Load_Tables('EMPLOYEE')

EXEC USP_Load_Tables('DEPARTMENT')

EXEC USP_Load_Tables('SUBJECT')

-------

----- -

EXEC USP_Load_Tables ('EMPLOYEE')
EXEC USP_Load_Tables ('DEPARTMENT')
EXEC USP_Load_Tables ('SUBJECT')
-------
-------

我们怎样才能从T-SQL脚本失败的角度实现循环逻辑。假设我们在Employee表中失败了,我需要执行下一个像Department,Subject,Marks这样的表。

How can we implement the Loop logic in T-SQL Script from the point of it's failure . Suppose if we got failed in at the Employee table leaving that I need to execute the next tables like Department ,Subject, Marks .

如何动态地执行这个过程,以便表名循环遍历过程。在我们内部有会话日志机制,它将插入记录

How can dynamically this procedure will execute so that table names will loop through the procedure . Inside the we have session log mechanism which will insert the records

因此会话表看起来像b elow

So that session table looks like below

推荐答案

您可以使用TRY ... CATCH ...跳过失败:

You can use TRY … CATCH … to skip the failure:

开始尝试&bbsp;                     ; EXEC USP_Load_Tables(Tbl_Name)

END TRY 

BEGIN CATCH 

     - 此处记录会话

END CATCH

在下一次运行中,检查Session表中的失败并在那里启动它。但是如果它需要更新那个会话成功。

In the next run, check the failures in the Session table and start it there. But you need to update that session if it is successful.


这篇关于如何使用循环条件或任何其他逻辑填充会话表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆