Sql server SQL Server:将数据库中的每个错误捕获到错误表中

Sql server SQL Server:将数据库中的每个错误捕获到错误表中,sql-server,database,error-handling,try-catch,hook,Sql Server,Database,Error Handling,Try Catch,Hook,我想知道如何在SQL Server中挂接某个数据库,使抛出的每个错误(没有人捕获)都被捕获并保存到数据库中的error\u表中。谢谢。您可以设置警报来执行此操作:使用错误号创建警报 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

我想知道如何在SQL Server中挂接某个数据库,使抛出的每个错误(没有人捕获)都被捕获并保存到数据库中的
error\u表中。谢谢。

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

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.

您可以使用扩展事件捕获sqlserver。报告的错误
。检查问题。