In my Windows application I use sqlCmd.ExecuteNonQuery() to execute the
stored procedure, In case of an error in the stored procedure I need to
return an exception to application, will RAISERROR in stored procedure
accomplish that?JIM.H.,
Yes.
Implementing Error Handling with Stored Procedures
http://www.sommarskog.se/error-handling-II.html
Error Handling in SQL Server – a Background
http://www.sommarskog.se/error-handling-I.html
AMB
"JIM.H." wrote:
> In my Windows application I use sqlCmd.ExecuteNonQuery() to execute the
> stored procedure, In case of an error in the stored procedure I need to
> return an exception to application, will RAISERROR in stored procedure
> accomplish that?|||For a full discussion of RAISERROR, refer to Books on Line.
You can use RAISERROR to 'thow' an error condition to the calling process.
Normally, you would have a condition to check, then use a BEGIN-END block to
both RAISERROR and then RETURN to the calling process. Without the RETURN,
any code after the RAISERROR will also execute.
i.e.,
IF {condition to check}
BEGIN
RAISERROR ("Error Occurred", 16, 1)
RETURN
END
Arnie Rowland*
"To be successful, your heart must accompany your knowledge."
"JIM.H." <JIMH@.discussions.microsoft.com> wrote in message
news:116D7CFD-FE3D-432B-B5DA-9A0CD93F744A@.microsoft.com...
> In my Windows application I use sqlCmd.ExecuteNonQuery() to execute the
> stored procedure, In case of an error in the stored procedure I need to
> return an exception to application, will RAISERROR in stored procedure
> accomplish that?
No comments:
Post a Comment