How to Handle the exceptions in Sqlsrver 2005??
Answer Posted / neetu
In SQLSERVER 2005 exceptions are handle by using RaisError
with Try catch like in other prog languages.
Begin Try
End try
Begin Catch
End Catch
BEGIN TRY
RAISERROR ('Yaa, I ma the problem', 16,1)
END TRY
BEGIN CATCH
SELECT ERROR_NUMBER() as ERROR_NUMBER,
ERROR_SEVERITY() as ERROR_SEVERITY,
ERROR_STATE() as ERROR_STATE,
ERROR_MESSAGE() as ERROR_MESSAGE
END CATCH
ERROR_NUMBER() returns the number of the error.
ERROR_SEVERITY() returns the severity.
ERROR_STATE() returns the error state number.
ERROR_PROCEDURE() returns the name of the stored procedure
or trigger where the error occurred.
ERROR_LINE() returns the line number inside the routine that
caused the error.
ERROR_MESSAGE() returns the complete text of the error
message. The text includes the values supplied for any
substitutable parameters, such as lengths, object names or
times.
| Is This Answer Correct ? | 3 Yes | 0 No |
Post New Answer View All Answers
How you trouble shoot when any job fails
How to use column default values in insert statements in ms sql server?
Can you import Microsoft Excel data to SSRS?
Difference between Logical Page and Physical Page in SSRS.
What is TDS(Tabular Data Stream) Gateway?
What do you understand by intent locks?
How would you add a section to a table?
Why use “pivot” in sql server?
What is the full form of ddl?
What do you mean by table and field in sql?
What are the advantages of sql azure?
What is an active database?
What is the use of RDBMS?
What is table-valued sub query?
How will you go about resolving deadlocks?