when i try to execute the below stored procedure exec usp_Example_ErrorHandlerthe below error is thrown:Msg 207, Level 16, State 1, Procedure usp_Example_ErrorHandler, Line 46Invalid column name 'notes'.Msg 266, Level 16, State 2, Procedure usp_Example_ErrorHandler, Line 46Transaction count after EXECUTE indicates a mismatching number of BEGIN and COMMIT statements. Previous count = 1, current count = 2.
notes column is not present in titles table..this is fine.but "Author table"is not getting rollbackedcan anyone correct the below stored proc:CREATE PROCEDURE usp_Example_ErrorHandler/* Example stored procedure to illustrate error handling * Example:DECLARE @RC intEXEC @RC = usp_Example_ErrorHandlerPRINT 'Return value = ' + CONVERT(varchar(10), @RC)****************************************************************/ ASDECLARE @myERROR int -- Local @@ERROR , @myRowCount int -- Local @@ROWCOUNTSET NOCOUNT ONBEGIN TRAN INSERT INTO Authors (au_id, au_fname, au_lname, contract) VALUES ('222-22-2222' , 'Andrew' , 'Novick' , 1 ) SELECT @myERROR = @@ERROR IF @myERROR != 0 GOTO HANDLE_ERROR INSERT INTO titles(title_id, title, type, price,notes, pubdate) VALUES('WW0790' , 'Transact-SQL User-Defined Functions' , 'popular_comp', 49.95 , 'Great book.', '2003-11-04') SELECT @myERROR = @@ERROR, @myRowCount = @@ROWCOUNT IF @myERROR != 0 GOTO HANDLE_ERROR INSERT INTO titleauthor (au_id, title_id) VALUES('222-22-2222', 'WW0790') SELECT @myERROR = @@ERROR, @myRowCount = @@ROWCOUNT IF @myERROR != 0 GOTO HANDLE_ERROR COMMIT TRAN -- No Errors, so go ahead RETURN 0HANDLE_ERROR: ROLLBACK TRAN RETURN @myERRORGO