sql-server - SQL Server : catch every error within a database into error table

标签 sql-server database error-handling try-catch hook

我想知道如何以某种方式钩住SQL Server中的某个数据库,使所引发的每个错误(没有人捕获)都将被捕获并保存到数据库的error_table中。谢谢。

最佳答案

您可以设置警报来执行以下操作:使用错误号创建警报

In Object Explorer, click the plus sign to expand the server where you want to create an alert using an error number.

Click the plus sign to expand SQL Server Agent.

Right-click Alerts and select New Alert.

In the New Alert dialog box, in the Name box, enter a name for this alert.
Check the Enable check box to enable the alert to run. By default, Enable is checked.

In the Type list, select SQL Server event alert.

Under Event alert definition, in the Database name list, select a database to restrict the alert to a specific database.

Under Alerts will be raised based on, Click Severity and then select the specific severity that will raise the alert.
You can add a job step to write to a table with the information from the alert.

关于sql-server - SQL Server : catch every error within a database into error table,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50008911/

相关文章:

ruby-on-rails - 使用 mongoid/mongodb 提取、建模和更改数据模型

java - Spring RestTemplate - 错误处理

php - 带左连接的 Mysql 查询 - 如果两行相同则专用索引

sql-server - 在 Microsoft SQL 中的单个过程中获取对作业的调用和复杂选择的结果

sql-server - T-SQL CTE 的性能特征

java - 为什么我在使用realm.executeTransactionAsync()方法时遇到编译时错误?

sql - @@ROWCOUNT 检查未检测到零行数

php - Smarty:从数据库返回数据

java - 泵事件错误cardLayout Java

design-patterns - 在没有案例结构的情况下如何在LabVIEW中将错误代码映射到字符串?