Reputation: 1293
I am using ExecuteNonQuery
to run an insert proc, it returns 2, but in actual I am inserting only 1 record. I am getting 1 extra due to trigger. Is there anyway that I get only actual number of rows affected. I do not want the rows affected by trigger.
Upvotes: 8
Views: 3944
Reputation: 2196
please refer below mention Image
However, the MSDN article on this function states: For UPDATE, INSERT, and DELETE statements, the return value is the number of rows affected by the command. For all other types of statements, the return value is -1. If a rollback occurs, the return value is also -1.
See... enter link description here
Upvotes: 0
Reputation: 460238
If you don't have it already, disable counting rows in your trigger:
SET NOCOUNT ON
For example:
CREATE TRIGGER [dbo].[triggerName] ON [dbo].[TableName]
AFTER INSERT
AS
SET NOCOUNT ON;
......
Upvotes: 9