简体   繁体   中英

SQL Server Stored Procedure call another Stored Procedure for Count

I have a stored procedure that I pass parameters and get a return based on a Select. I created a second stored procedure that does the same thing except it returns a count.

I was wondering since it seems redundant - how to call the first stored procedure and simply perform a count on it?

What I would like to do.... example:

execute spRunReportByTime

returns:

ID User Type
1  abc  123
2  cde  345

then I would want to run the second procedure:

execute spRunReportByTimeCOUNT 

it would call spRunReportByTime return the count from that procedure

2

Right now the second procedure has the same code in it but a Select count(id)

也许您可以合并为一个将计数作为out参数返回的proc,或者只是将计数作为新列添加到结果集中?

在第一个存储过程的底部添加以下内容

 Select @@ROWCOUNT 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM