This is the thread of my stored procedure :
ALTER procedure dbo.usp_DoSomething as declare @Var1 int declare @Var2 int declare @Var3 int select @Var1 = Var1, @Var2 = Var2, @Var3 = Var3 from Table where ... BEGIN TRY BEGIN TRANSACTION COMMIT TRAN END TRY BEGIN CATCH IF @@TRANCOUNT > 0 ROLLBACK TRAN END CATCH
Running UPDATE . INSERT fails, so transaction discarded.
After execution, the table looks right and nothing has changed. But when I start SP, I get the following messages:
(1 row(s) affected) (0 row(s) affected)
So, I ask myself: where did the first 1 row(s) affected come from?
Then I think this is the reason, but I wanted to confirm: OUTPUT clause (Transact-SQL)
An UPDATE, INSERT, or DELETE statement that has an OUTPUT clause will return rows to the client even if the statement encounters errors and is rolled back. The result should not be used if any error occurs when you run the statement.
sql sql-server tsql sql-server-2008
rbhat
source share