SQL Server: перехватывать каждую ошибку в базе данных в таблицу ошибок - PullRequest
0 голосов
/ 24 апреля 2018

Интересно, как мне перехватить определенную базу данных в SQL Server таким образом, чтобы каждая ошибка, которая генерируется, и которую никто не ловит, была перехвачена и сохранена в error_table в моей базе данных.Благодаря.

1 Ответ

0 голосов
/ 24 апреля 2018

Вы можете настроить оповещение, чтобы сделать это: Чтобы создать оповещение, используя номер ошибки

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