Solved

Looking for good sample of TSQL error-handling

Posted on 2008-10-15
4
173 Views
Last Modified: 2010-04-21
Please point me to a page or provide me with a nice sample of error-handling with TSQL.
0
Comment
Question by:jdana
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 37

Expert Comment

by:momi_sabag
ID: 22719551
which sql server version?
0
 
LVL 37

Accepted Solution

by:
momi_sabag earned 250 total points
ID: 22719560
for v2005 and v2008 it's quite simple:

begin try
 do your code here...
end try
begin catch
 do your code here
end catch

inside the catch you can use error_number() and error_message() in order to understand which error happended

in sql 2000 you will have to use the @@error variable
0
 

Author Comment

by:jdana
ID: 22719641
Version 2005
0
 

Author Closing Comment

by:jdana
ID: 31506248
Thanks!
0

Featured Post

Raise the IQ of Your IT Alerts

From IT major incidents to manufacturing line slowdowns, every business process generates insights that need to reach the people required to take action. You need a platform that integrates with your business tools to create fully enabled DevOps toolchains.

You need xMatters.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question