KJ3
KJ3

Reputation: 5298

SQL Server Enable Logging for Certain Error Codes

I would like to get alerts when certain database errors occur. For instance, if a table or stored procedure is queried against that no longer exists, I want an alert.

I've tried creating alerts for these error codes (208, 2812) but they never trigger, no doubt due to the fact that there are only a handful of error codes that are logged, according to the docs.

From sys.messages:

Error Severity Event Logged Description
208 16 No Invalid object name '%.*ls'.
2812 16 No Could not find stored procedure '%.*ls'.

Is there a way to change the event logged status?

Upvotes: 0

Views: 226

Answers (1)

KJ3
KJ3

Reputation: 5298

Turns out there's a SP to do it, sp_altermessage. Docs

exec SP_ALTERMESSAGE 208, 'WITH_LOG', 'TRUE'

Upvotes: 1

Related Questions