您的位置:首页 > 数据库

using try catch finally in SQL

2010-10-20 15:25 561 查看
-- sorry, it looks so like the assemble language struct



-- when power not enough, or memory capacity not enough, or other reasons
delete from table1 where id='123456789'

-- @@ERROR is a global error variable, it will err when its variable is not 0
if @@ERROR!=0 goto catch
-- do something, when all are right.



-- after do something, you should go to do final thing
goto finally



catch:
print 'an exception has occured!'



finally:
print 'do something finally'
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: