Medical record policies & procedure in the hospital?

@@ERROR returns ''1'' in SQL Server 2005 stored procedure but procedure executes successfully. Please Help?

  • Guys, below is my stored procedure in sql server 2005. The problem is, @@ERROR is returning 1 however the procedure executes successfully and deletes the record. I have a check on front end that if @@ERROR returns 0 then display a ''success'' message otherwise display a "'failure'' message. In this case, ''failure'' message is being displayed however record is being deleted successfully. Please help me where I am doing wrong. ALTER PROCEDURE [dbo].[sp_Teams_DELETE] ( @teamID int ) AS DELETE [dbo].[tbl_Teams] WHERE [TeamID] = @teamID RETURN @@ERROR

  • Answer:

    1. Make sure the delete actually worked. 2. Try a workaround by trapping @@error in an integer local variable and then returning that variable. 3. Try printing @@error and see what you have. 4. Might be due to some scope termination issues. Check if the variable that you are assigning the return value of the SP is an integer variable. 5. Return the @@error value in an output variable to the SP and see if that helps. In short, I do not know the exact reason why this is happening without the entire context. But these are some food for thought.

PuraniJe... at Yahoo! Answers Visit the source

Was this solution helpful to you?

Other answers

commitALTER PROCEDURE [dbo].[sp_Teams_DELETE] ( @teamID int ) AS DELETE [dbo].[tbl_Teams] WHERE [TeamID] = @teamID tran A if @@ERROR = 0 commit tran A else rollback tran A RETURN @@ERROR end now if any error data will roll back

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.