using try catch finally in SQL

简介: -- sorry, it looks so like the assemble language struct   -- when power not enough, or memory capacity not enough, or other...

-- 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'

目录
打赏
0
0
0
0
20
分享
相关文章
T-SQL编程中的异常处理-异常捕获(try catch)与抛出异常(throw)
原文:T-SQL编程中的异常处理-异常捕获(try catch)与抛出异常(throw)   本文出处: http://www.cnblogs.com/wy123/p/6743515.html     T-SQL编程与应用程序一样,都有异常处理机制,比如异常的捕获与异常的抛出(try catch throw),本文简单介绍异常捕获与异常抛出在T-SQL编程中的实际使用 。
1927 0
在Sql中使用Try Catch
原文:在Sql中使用Try Catch 今天在写sql中出现了!我想在sql使用trycatch吧! 哎..但是语法又记不住了! 那就清楚我们的google大师吧! 嘿,网上关于在sql中使用Try Catch的还有真不少的文章! 闲话就少了! 今天记录下来以便下次使时查阅! 创建错误日志表: C...
803 0
5-10Can't connect to MySQL server on 'sh-cynosl-grp-fcs50xoa.sql.tencentcdb.com' (110)")
5-10Can't connect to MySQL server on 'sh-cynosl-grp-fcs50xoa.sql.tencentcdb.com' (110)")
|
8月前
|
SQL Server的并行实施如何优化?
【7月更文挑战第23天】SQL Server的并行实施如何优化?
197 13
|
8月前
|
SQL
解锁 SQL Server 2022的时间序列数据功能
【7月更文挑战第14天】要解锁SQL Server 2022的时间序列数据功能,可使用`generate_series`函数生成整数序列,例如:`SELECT value FROM generate_series(1, 10)。此外,`date_bucket`函数能按指定间隔(如周)对日期时间值分组,这些工具结合窗口函数和其他时间日期函数,能高效处理和分析时间序列数据。更多信息请参考官方文档和技术资料。
118 9
对比 SQL Server中的VARCHAR(max) 与VARCHAR(n) 数据类型
【7月更文挑战7天】SQL Server 中的 VARCHAR(max) vs VARCHAR(n): - VARCHAR(n) 存储最多 n 个字符(1-8000),适合短文本。 - VARCHAR(max) 可存储约 21 亿个字符,适合大量文本。 - VARCHAR(n) 在处理小数据时性能更好,空间固定。 - VARCHAR(max) 对于大文本更合适,但可能影响性能。 - 选择取决于数据长度预期和业务需求。
617 1

热门文章

最新文章

AI助理

你好,我是AI助理

可以解答问题、推荐解决方案等