Solved

Looking for good sample of TSQL error-handling

Posted on 2008-10-15
4
171 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Viewers will learn how the fundamental information of how to create a table.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

726 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