1 / 5

Database Mail

Sql server. Database Mail. EXECUTE msdb.dbo.sp_send_dbmail @profile_name = ‘HRMail’, @recipients = ‘Gregory.House@adventureworks.com’, @copy_recipients = ‘Administrator@adventureworks.com’, @body = ‘Your data has been successfully imported!’,

buzz
Download Presentation

Database Mail

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Sql server Database Mail

  2. EXECUTE msdb.dbo.sp_send_dbmail • @profile_name = ‘HRMail’, • @recipients = ‘Gregory.House@adventureworks.com’, • @copy_recipients = ‘Administrator@adventureworks.com’, • @body = ‘Your data has been successfully imported!’, • @subject = ‘Import Notification Message - Success’;

  3. EXECUTE msdb.dbo.sp_send_dbmail • @profile_name = ‘HRMail’, • @recipients = ‘Lisa.Cuddy@adventureworks.com’, • @blind_copy_recipients = ‘Gregory.House@adventureworks.com; • Administrator@adventureworks.com’, • @body = ‘Per your request, here are the employees hired in 2002.’, • @query = ‘SELECT Person.Person.FirstName AS First, • Person.Person.LastName AS Last, • HumanResources.Employee.HireDate AS [Date of Hire] • FROM Person.Person INNER JOIN HumanResources.Employee • ON Person.Person.BusinessEntityID = HumanResources.Employee.BusinessEntityID • WHERE HireDate > ‘’2002-01-01" AND HIREDATE < ‘’2003-01-01’’ • ORDER BY HireDate’, • @execute_query_database = ‘AdventureWorks2008’, • @subject = ‘Employees Hired in 2002’, • @attach_query_result_as_file = 1;

  4. Managing Messages • SELECT * FROM msdb.dbo.sysmail_mailitems • EXECUTE msdb.dbo.sysmail_delete_mailitems_sp • @sent_before = ‘January 31, 2009’ ; • EXECUTE msdb.dbo.sysmail_delete_mailitems_sp • @sent_status = ‘failed’;

  5. sp_send_dbmail @profile_name, @recipients, @copy_recipients, @blind_copy_recipients, @subject, @body, @body_format, @importance, @sensitivity, @file_attachments, @query, @execute_query_ • Database, @attach_query_result_ • as_file, @query_attachment_ • filename

More Related