Look for @@error and raiserror in BOL.
You can build your own custom error handler.
for example:
'Do some T-SQL coding
if @@error <> 0
begin
raiserror('THis is the error description: Some Error', 1, 16)
end
Then you can catch this error from your application.
For example if you use ASP:
On Error Resume Next
'Execute the sp
If Err.Number <> 0 then
Response.Write ("Error Number = " & Err.Number &"<br>")
Response.Write ("Error Description = " & Err.Description &"<br>")
End If
The Err.Description holds the "THis is the error description: Some Error"
string you wrote above.
Of course you can catch all the other SQL SERVER errors, with the same code:
'Execute the sp
If Err.Number <> 0 then
Response.Write ("Error Number = " & Err.Number &"<br>")
Response.Write ("Error Description = " & Err.Description &"<br>")
End If
Hope it helps.
Lefteris.
-----Original Message-----
From: Clifton Dunaway [mailto:csdunaway@y...]
Sent: Friday, September 21, 2001 4:11 PM
To: sql language
Subject: [sql_language] How to Suppress Errors in a Stored Proc
I need a way to suppress errors from a stored proc. For instance, If an
insert tries to add a duplicate identity, I need a way to suppress the
error, but I would like to capture the error string to return as a
parameter.
Hope someone can help!