计算存储过程结果中的行数,然后将结果插入表中 [英] Count # of Rows in Stored Procedure Result, then Insert result into table

查看:41
本文介绍了计算存储过程结果中的行数,然后将结果插入表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 SSIS 包,它将首先运行我的 sp_doSomething.这个存储过程将从几个不同的表中选择数据并将它们连接起来,以便可能的存储到 dbo.someTable 中.但我只希望如果选择 > 1 行选定数据.

I have an SSIS package which will first run my sp_doSomething. This stored procedure will select data from several different tables and join them for possible storage into dbo.someTable. But I only want that IF the select is > 1 row of selected data.

然后我想有一个优先级限制来查看我的存储过程返回的行数.

I want to then have a precedence restraint that looks at the amount of rows my stored procedure returned.

如果我的行数 > 1,那么我想获取存储过程的结果并将它们插入到我的一个表中.

If my row count > 1, then I want to take the results of the stored procedure and insert them into one of my tables.

否则,我将记录错误/发送电子邮件或其他任何内容.

Otherwise, I will record an error/send an email, or whatever.

我真的不想多次运行这个存储过程,但这是我能想到的唯一方法(运行它,计算行数.然后,再次运行并插入结果).

I really don't want to run this stored procedure more then once, but that is the only way I could think to do it (Run it, count the rows. Then, run it again and insert the result).

我是一个完整的 TSQL/SSIS 新手.所以如果这个问题微不足道,我很抱歉.我在任何地方都找不到好的答案.

I'm a complete TSQL/SSIS newb. So I'm sorry if this question is trivial. I can't find a good answer anywhere.

推荐答案

创建一个包作用域为 Int32 类型并命名为 rowcount 的变量.

Create a variable with Package Scope of type Int32 and name rowcount.

这篇关于计算存储过程结果中的行数,然后将结果插入表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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