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
Explain about remote stored procedure?
If you are given access to a SQL Server, how do you find if the SQL Instance is a named instance or a default instance?
How to generate create function script on an existing function?
difference between Clustered index and non clustered index ?
What is difference between clustered and non clustered index?
Can foreign key be deleted?
You are creating an application where users are asked their gender in the gender combo box you have three options: ‘male’ , ‘female’ and ‘i choose not to disclose’ these options are stored in the table as 1, 0 or null which datatype should you use?
What is a data source file?
What is indexing explain it with an example?
What are the system database in sql server 2005?
How to create sub reports?
How to filter records of table in SQL SERVER?
What are window functions in sql server?
can a database be shrunk with users active? : Sql server administration
Does a full backup include transaction log?