-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathmonitor-errors-create.sql
35 lines (33 loc) · 1008 Bytes
/
monitor-errors-create.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
-----------------------------------------------------------------
-- Tracks exceptions (severity > 10)
--
-- [email protected], go ahead license
-----------------------------------------------------------------
CREATE EVENT SESSION [errors] ON SERVER
ADD EVENT sqlserver.error_reported(
ACTION(
sqlserver.client_app_name,
sqlserver.client_hostname,
sqlserver.database_name,
-- sqlserver.query_hash,
sqlserver.sql_text,
sqlserver.tsql_stack,
sqlserver.username)
WHERE ([severity]>(10)))
ADD TARGET package0.event_file(SET filename=N'errors',max_file_size=(50))
WITH (
MAX_MEMORY=4096 KB,
EVENT_RETENTION_MODE=ALLOW_SINGLE_EVENT_LOSS,
MAX_DISPATCH_LATENCY=30 SECONDS,
MAX_EVENT_SIZE=0 KB,
MEMORY_PARTITION_MODE=NONE,
TRACK_CAUSALITY=OFF,
STARTUP_STATE=OFF
)
GO
-- start the session
ALTER EVENT SESSION [errors] ON SERVER STATE=START;
-- stop the session
/*
ALTER EVENT SESSION [errors] ON SERVER STATE=STOP;
*/