How do I capture @@ROWCOUNT from a stored procedure?
Greetings, I have a stored procedure that does updates. The sproc is called from an Exec SQL Task. The sproc returns the number of rows that were updated using this technique: RETURN @@ROWCOUNT How do I capture the sprocs return value (number of rows) in a package-level variable? I eventually want to log this value. The sproc is not returning a result set. Im new to SSIS so any general guidance would be appreciated. Thanks, BCB
December 5th, 2006 9:58am

I presume you don't have any trouble grabbing this value when you execute outside SSIS? In this case then the only extra info you need is how to get info out of the Execute SQL Task. There is a great article here: The ExecuteSQL Taskhttp://www.sqlis.com/default.aspx?58 that covers the Execute SQL Task in depth. -Jamie
Free Windows Admin Tool Kit Click here and download it now
December 5th, 2006 10:07am

The simplest thing is to change your RETURN to SELECT @@ROWCOUNT. Then set the sql task to "single row" return and map a variable to parameter 0.
December 5th, 2006 12:51pm

Thanks for your reply. I found it was easy to capture the @@ROWCOUNT to a variable once I started returning it as a result set rather than the sproc return value. Thanks for your tip. For some reason I was never able to capture the @@ROWCOUNT value as the sproc return value. BCB
Free Windows Admin Tool Kit Click here and download it now
December 6th, 2006 9:37am

BlackCatBone wrote: Thanks for your reply. I found it was easy to capture the @@ROWCOUNT to a variable once I started returning it as a result set rather than the sproc return value. Thanks for your tip. For some reason I was never able to capture the @@ROWCOUNT value as the sproc return value. BCB How come? Did you try and pass it using an output paremter? -Jamie
December 6th, 2006 12:30pm

BlackCatBone wrote: Thanks for your reply. I found it was easy to capture the @@ROWCOUNT to a variable once I started returning it as a result set rather than the sproc return value. Thanks for your tip. For some reason I was never able to capture the @@ROWCOUNT value as the sproc return value. BCB How come? Did you try and pass it using an output paremter? -Jamie
Free Windows Admin Tool Kit Click here and download it now
December 6th, 2006 12:30pm

can u plss explain how you were able to solve this ...i have a similar situation...
July 27th, 2012 1:52pm

@@rowcount example in SSIS: http://microsoft-ssis.blogspot.com/2011/03/rowcount-for-execute-sql-statement.htmlPlease mark the post as answered if it answers your question | My SSIS Blog: http://microsoft-ssis.blogspot.com | Twitter
Free Windows Admin Tool Kit Click here and download it now
July 27th, 2012 2:20pm

@@rowcount example in SSIS: http://microsoft-ssis.blogspot.com/2011/03/rowcount-for-execute-sql-statement.htmlPlease mark the post as answered if it answers your question | My SSIS Blog: http://microsoft-ssis.blogspot.com | Twitter
July 27th, 2012 2:25pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics