BEGIN TRY
-- Generate a constraint violation error.
DELETE FROM Production.Product
WHERE ProductID = 980;
END TRY
BEGIN CATCH
SELECT
ERROR_NUMBER() AS ErrorNumber,
ERROR_SEVERITY() AS ErrorSeverity,
ERROR_STATE() as ErrorState,
ERROR_PROCEDURE() as ErrorProcedure,
ERROR_LINE() as ErrorLine,
ERROR_MESSAGE() as ErrorMessage; IF @@TRANCOUNT > 0
ROLLBACK TRANSACTION;
END CATCH; IF @@TRANCOUNT > 0
COMMIT TRANSACTION;
GO
相关文章
- 02-11SQL在数据处理过程中,遇到除数为0该怎么办?
- 02-11SQL语句将两个select语句查询结果合并一个
- 02-11从"UDF不应有状态" 切入来剖析Flink SQL代码生成
- 02-11SQL 无法解决 EQUAL TO 运算中 "CHINESE_PRC_CI_AS" 和 "CHINESE_PRC_90_CI_AI" 之间的排序规则冲突
- 02-11sql中,In和where的区别
- 02-11【入门推荐】SQL注入进行WebShell渗透测试的基础概览
- 02-11SQL篇 语句练习 难度(中等)
- 02-11达梦数据库DM8开启sql日志
- 02-11SQL基础知识V2——JOIN连接
- 02-11sql等值连接,左右连接