Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
SQL Server Tacklebox- P31: This book, as with almost all books, started out as an idea. I wanted to accumulate together those scripts and tools that I have built over the years so that DBAs could sort through them and perhaps adapt them for their own circumstances. | 6 Monitoring and notifications rlandruml 3@cox.net D BA Account Manage Existing Account Choose the account to view change or delete. Account name Description Outgoing mail server SMTP E-mail address Display name Reply e-mail Server name rlandruml 3@cox.net Y our. smtp. server com Port number 25 Q This server requires a secure connection SSL SMTP Authentication o Windows Authentication using Database Engine service credentials o Basic authentication User name Password Confirm password Anonymous authentication Figure 6.2 Database Mail account settings associated with the Notifications profile. Having configured Database Mail with a default profile and account both tasks thankfully having guided wizards you can send a test mail using the stored procedure sp_send_dbmail. The options for this stored procedure are many but a simple test can be performed with the code shown in Listing 6.1. msdb.sp_send_dbmail @recipients N rlandrum13@cox.net @subject N Mail must work or else. @body N This is a level 1 alert.please wake up to failure. Listing 6.1 Sending a test mail using sp_send_dbmail. NOTE You may notice that sp_send_dbmail is now located in the MSDB database whereas xp_sendmail in versions prior to SQL Server 2005 was located in the Master database. 150 6 Monitoring and notifications If all went well with the test you should receive a test message similar to that shown in Figure 6.3 and yes that is Outlook Express. I will not apologize . Figure 6.3 Mail received from sp_send_dbmail. While Database Mail is certainly important for sending mail from code such as maintenance stored procedures it is only one part of the notification system that the DBA will use if he or she is diligent. You will also want to configure SQL Agent to use Database Mail for scheduled jobs that execute the code. In this way you will have built in redundancy of notifications one message coming from the code and one message coming from the SQL Agent service that executed the job code. To configure