[dba-VB] C# - Records Affected

jwcolby jwcolby at colbyconsulting.com
Tue Dec 1 10:07:22 CST 2009


I am trying to get a count of records appended, updated etc in my SPs and returning that to my C# 
supervisor.  I am finding references to @@Rowcount however this is returning 1 instead of the actual 
number.

Is this @@RowCount the real deal?

The SP definition:

ALTER PROCEDURE [dbo].[sp_AZOut_AZExportToOrderedChunk]
	-- Add the parameters for the stored procedure here
	@DBName varchar(50),
	@ErrorDesc varchar(4000) output,
	@ErrorNo int output,
	@RecsAffected int output

AS
BEGIN


Setting the returned value

	EXEC (@SQL)
	select @RecsAffected = @@RowCount

My c# code:

intRecsAffected = sCmd.Parameters["@RecsAffected"].Value

The code triggers the try block if there is no such parameter (I just ignore it) or returns 1 if the 
parameter exists.

This is a functioning tested SP which typically appends millions of records, though the exact number 
depends on the database.

Is there something I need to know here?
-- 
John W. Colby
www.ColbyConsulting.com



More information about the dba-VB mailing list