Download Database Mail - Zanjan University of Medical Sciences

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Sql server






EXECUTE msdb.dbo.sp_send_dbmail
@profile_name = ‘HRMail’,
@recipients =
‘[email protected]’,
@copy_recipients =
‘[email protected]’,
@body = ‘Your data has been successfully
imported!’,
@subject = ‘Import Notification Message Success’;
















EXECUTE msdb.dbo.sp_send_dbmail
@profile_name = ‘HRMail’,
@recipients = ‘[email protected]’,
@blind_copy_recipients = ‘[email protected];
[email protected]’,
@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;

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’;




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
Related documents