• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 179
  • Last Modified:

Looking for good sample of TSQL error-handling

Please point me to a page or provide me with a nice sample of error-handling with TSQL.
0
jdana
Asked:
jdana
  • 2
  • 2
1 Solution
 
momi_sabagCommented:
which sql server version?
0
 
momi_sabagCommented:
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
 
jdanaAuthor Commented:
Version 2005
0
 
jdanaAuthor Commented:
Thanks!
0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now