Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error Message with Sql Server 2000 Stored Procedure

Status
Not open for further replies.

saw15

Technical User
Jan 24, 2001
468
US
I am trying to run a sp and getting the following error message:

A RETURN statement with a return value cannot be used in this context.

IF @@ERROR <> 0
BEGIN
RAISERROR('Error on updating history_load_log_reject, error number %d',15,1,@@error)
RETURN @@ERROR
END
GO

Any assistance / thoughts as to why would be appreciated.
 
Hi

Your code appears OK to me

Try

IF @@ERROR <> 0
RETURN @@ERROR

and see if you still get the error

Regards

sadcow
 
Just tried it, still getting the same error. I can tell you that the if portion is not getting executed because the @@error is = 0.

I can remove the @@Error after return and it runs as expected.

Any other thoughts ?
 
Can you please post the entire stored procedure? Did you declare @@ERROR within the stored procedure? @@ERROR is reserved, so if you declare it, then you would get the error when you try to return it.

Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top