Question
How do I handle error checking in a stored procedure?

Answers

The simplest method for handling errors in T-SQL is very similar to the "on error resume next" struct we're stuck
with in ASP:
BEGIN TRANSACTION
-- statement that might cause error
IF @@ERROR != 0
BEGIN
ROLLBACK TRANSACTION
RAISERROR('There was an error here.', 11, 1)
RETURN
END
ELSE
COMMIT TRANSACTION
This is not pretty, and will not catch all errors (some errors, depending on their severity, will terminate the batch
before you can even catch the value from @@ERROR).
For a much more thorough discussion of error handling in SQL Server, see Erland's articles:
Error Handling in SQL Server – a Background
Implementing Error Handling with Stored Procedures
  Your Comment




More Software Questions..
What is the inputsplit in map reduce software?

What is software configuration management?

What Is Java Api For Xml-based Rpc (jax-rpc)?

How can you implement fine-grained auditing?

What is IBM’s simple explanation for Big Data’s four critical features?

What is static synchronized method in JDBC API? Give an example?

What does the NULLIF function do?

What happens if a start method is not invoked and the run method is directly invoked?

Should we override finalize method

what is the difference between mysql_fetch_array and mysql_fetch_object?

How will XML affect my document links?

Why to use Style Sheets?

What are Filters in MVC?

Can you explain Application layer in OSI model?

How to define new testplan attributes?

What are the minimum system requirements to run Photoshop? Is it possible to run Photoshop over linux?

Which oracle package is used to manage the oracle lock management services?

What is Latch Up? Explain Latch Up with cross section of a CMOS Inverter. How do you avoid Latch Up?

What is marker interface?

What types of partitioning are there for BW?



Search
Can you Answer!!
  • Q Explain Event handling in GWT.
  • Q If there are no indexes defined on any of the columns in the above two tables, which columns would you index to speed up the left join query?
  • Q How flow can be measured with dp?
  • Q "Critical values are not monotonic for these data. Substitutions have been made to ensure monotonicity. Type I error is therefore smaller."? Antimicrobial analysis of various extracts of plants were tested against different pathogenic microbes and their activities were measured in terms of zone of inhibition (mm). Standard commercially available antibiotic disc were also used as a positive control while applying the extracts using well diffusion method.Applying DUNCAN test through spss, what does the statement means as given below: "Critical values are not monotonic for these data. Substitutions have been made to ensure monotonicity. Type I error is therefore smaller?
  • Q What is the common name for the round skullcap worn by Jewish males?
  • Q The Capital and Currency of Switzerland is
  • Q What is the difference between top down approach and bottom up approach in programming languages?
  • Q Have you worked on insurance or patient accounts receivables?
  • Q The annual tree planting festival in India initiated in 1950 is:
  • Q How is xhtml better than html? why would you want to use xhtml?
  • Q The number of parliamentary seats (Lok Sabha) of Andhara Pradesh is