Hi,I'm using TRY CATCH block for error handling and reporting but the @@ROWCOUNT does not seem to work here.My Code:BEGIN TRY SELECT TOP 10 * FROM [TableName]END TRYBEGIN CATCH SELECT ERROR_NUMBER() AS ErrorNumber, ERROR_SEVERITY() AS ErrorSeverity, ERROR_STATE() AS ErrorState, ERROR_PROCEDURE() AS ErrorProcedure, ERROR_LINE() AS ErrorLine, ERROR_MESSAGE() AS ErrorMessage; /* log message */ --ERROR Log Message Section SELECT @intRowCount = @@ROWCOUNT, @intErrorCode = ERROR_NUMBER(), @intErrorMessage = ERROR_MESSAGE();Insert all the above in a log message table RAISERROR (@chrMessageFailure , 16, 1) RETURN @intErrorCodeEND CATCH;/* log message */--SUCCESS Log Message SectionSELECT @intRowCount = @@ROWCOUNT;Insert all the above in a log message table
Now in log messages table, the row count is coming up as 0 whereas it should be 10. Any suggestions will be much appreciated.Thanks