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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Counting Errors from stored procedure execution

Status
Not open for further replies.

thegeezza

Technical User
Jan 24, 2004
27
0
0
GB
Afternoon,

Essentially I want to increment an error counter each time an error is encountered executing a stored procedure. So for example.....
Code:
exec @custom_error = sp_executesql @sql
..... will catch the return status from the procedure. What I would like to do is this following which of course is illegal.
Code:
exec @custom_error =  @custom_error + (sp_executesql @sql)
Can anyone suggest a neat method for doing this?

Regards,
TheGeezza
 
Different ways you can do this depending on what exactly you are trying to measure.
You could create a temp table and increment the value from within the stored procedure.

You could do something similiar to what you have above.
Code:
declare @custom_error_total int
exec @custom_error = sp_executesql @sql
set @custom_error_total = @custom_error_total + @custom_error

Lots of different ways.


"I'm living so far beyond my income that we may almost be said to be living apart
 
Afternoon,

Thanks for your reply. I think the variable route is the best method as I am guessing it will be the most efficient.

Many Thanks,
TheGeezza
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top