IO figyelmeztetések

Az alábbi figyelmeztetéseket ajánlott minden SQL Server esetében beállítani. A kód kommentjeiben van leírás mindegyikről, illetve a hozzá tartozó Technet cikk is megtalálható. Az értesítéshez emailt használ az alábbi kód, mely feltételezi, hogy a Database Mail szolgáltatás engedélyezve van és beállításra is került.

 1DECLARE @EmailAddress varchar(100);
 2SET @EmailAddress = '<your email address>';
 3 
 4/*
 5A Windows read or write request has failed.
 6The error code that is returned by Windows and the corresponding text are inserted into the message.
 7In the read case, SQL Server will have already retried the read request four times.
 8This error is often the result of a hardware error, but may be caused by the device driver.
 9For more information about error 823, see http://support.microsoft.com/kb/828339.
10*/
11USE [msdb];
12 
13EXEC msdb.dbo.sp_add_alert @name=N'ERROR_823',
14            @message_id=823,
15            @severity=0,
16            @enabled=1,
17            @delay_between_responses=0,
18            @include_event_description_in=1,
19            @job_id=N'00000000-0000-0000-0000-000000000000';
20             
21EXEC msdb.dbo.sp_add_notification @alert_name=N'ERROR_823', @operator_name=@EmailAddress, @notification_method = 1;
22/*
23This error indicates that Windows reports that the page is successfully read from disk,
24but SQL Server has discovered something wrong with the page.
25This error is similar to error 823 except that Windows did not detect the error.
26This usually indicates a problem in the I/O subsystem, such as a failing disk drive, disk firmware problems, faulty device driver, and so on.
27http://msdn.microsoft.com/en-us/library/aa337274.aspx
28*/
29EXEC msdb.dbo.sp_add_alert @name=N'ERROR_824',
30            @message_id=824,
31            @severity=0,
32            @enabled=1,
33            @delay_between_responses=0,
34            @include_event_description_in=1,
35            @job_id=N'00000000-0000-0000-0000-000000000000';
36             
37EXEC msdb.dbo.sp_add_notification @alert_name=N'ERROR_824', @operator_name=@EmailAddress, @notification_method = 1;
38 
39/*
40This message indicates that the read operation had to be reissued at least one time, and indicates a major problem with the disk hardware.
41This message does not currently indicate a SQL Server problem, but the disk problem could cause data loss or database corruption if it is not resolved.
42The system event log may contain related events that help to diagnose the problem.
43http://msdn.microsoft.com/en-us/library/aa337447.aspx
44*/
45EXEC msdb.dbo.sp_add_alert @name=N'ERROR_825',
46            @message_id=825,
47            @severity=0,
48            @enabled=1,
49            @delay_between_responses=0,
50            @include_event_description_in=1,
51            @job_id=N'00000000-0000-0000-0000-000000000000';
52             
53EXEC msdb.dbo.sp_add_notification @alert_name=N'ERROR_825', @operator_name=@EmailAddress, @notification_method = 1;
54 
55/*
56This message indicates that SQL Server has issued a read or write request from disk, and that the request has taken longer than 15 seconds to return.
57This error is reported by SQL Server and indicates a problem with the IO subsystem.
58 
59Possible Causes
60This problem can be caused system performance issues, hardware errors, firmware errors, device driver problems, or filter driver intervention in the IO process.
61 
62http://msdn.microsoft.com/en-us/library/aa337269.aspx
63*/
64EXEC msdb.dbo.sp_add_alert @name=N'ERROR_833',
65            @message_id=833,
66            @severity=0,
67            @enabled=1,
68            @delay_between_responses=0,
69            @include_event_description_in=1,
70            @job_id=N'00000000-0000-0000-0000-000000000000';
71             
72EXEC msdb.dbo.sp_add_notification @alert_name=N'ERROR_833', @operator_name=@EmailAddress, @notification_method = 1;