在 SSIS 中,如何获取从 Source 返回的应该处理的行数
我正在开展一个项目,以将日志记录添加到我们的 SSIS 包中.我通过实现一些事件处理程序来做我自己的自定义日志记录.我已经实现了 OnInformation 事件以将时间、源名称和消息写入日志文件.当数据从一个表移动到另一个表时,OnInformation 事件会给我一条消息,例如:
I am working on a project to add logging to our SSIS packages. I am doing my own custom logging by implementing some of the event handlers. I have implemented the OnInformation event to write the time, source name, and message to the log file. When data is moved from one table to another, the OnInformation event will give me a message such as:
组件 "TABLENAME" (1)" 写了 87 行.
component "TABLENAME" (1)" wrote 87 rows.
如果其中一行失败,假设只处理了预期的 87 行中的 85 行.我假设上面的行将读取 wrote 85 rows
.在这种情况下,我如何跟踪应该处理多少行?我希望看到类似 write 85 of 87 rows
的内容.基本上,我想我需要知道如何获取源查询返回的行数.有没有简单的方法可以做到这一点?
In the event that one of the rows fails, and lets say only 85 rows were processed out of the expected 87. I would assume that the above line would read wrote 85 rows
. How do I track how many rows SHOULD HAVE processed in this case? I would like to see something like wrote 85 of 87 rows
. Basically, I think I need to know how to get the number of rows returned from the Source's query. Is there an easy way to do this?
谢谢
推荐答案
可以使用Data source后面的Row Count transaformation
并将其保存为变量.这将是要处理的行数.一旦它被加载到目标中,您应该使用 Control flow
中的 Execute SQL Task
并使用 Select Count(*) from <<DestinationTable>>
并将计数保存到其他变量中[您应该在查询中使用 Where 子句来识别当前负载].因此,您将处理数字行以进行日志记录.
You can use the Row Count transaformation
after the Data source and save it the variable. This is going to be number of rows to be processed. Once it got loaded into the Destination, you should use the Execute SQL Task
in Control flow
and use Select Count(*) from <<DestinationTable>>
and save the count into the Other variable[You should use the Where clause in your query to identify the current load]. So you will have number rows processed for logging.
希望这会有所帮助!
相关文章