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
What are pages and extents? : SQL Server Architecture
What is difference between inner join and full join?
What is the difference between push and pull subscription? : sql server replication
1.what are diff types of joins , and explain diff between cross join and full outer join 2.diff types of views 3. Diff types of index 4. What is diff b/w stores procedure and function procedure 5.diff between double and int in SQL 6.diff between char and varchar in SQL. 7.Oracle or SQL whice you will preferred and why.
What is data block and how to define data block size?
What is the difference between join and inner join?
Which is the best place or learning center for MS SQL?????In Bangladesh?????
How do you delete duplicate records in sql server?
What the different topologies in which replication can be configured?
How to set database to be single_user in ms sql server?
What are the advantages dts has over bcp?
What are user defined functions in ms sql server?
How many types of built in functions are there in sql server 2012?
What is not null constraint?
What is sql server profiler?