Monday, July 20, 2009

send query from email from database

EXEC msdb.dbo.sp_send_dbmail
@recipients='maia.eliozashvili@vancleef.com',
@subject = 'SQL Mail Test',
@body_format = 'html', --text or html
@body = 'body1' ,
@query = 'use vcadata
select
itemno
from itemmaster
where
year(createdate)=year(getdate()) and month(createdate)=month(getdate())',
@attach_query_result_as_file = 0
--@query_attachment_filename ='Results.txt'

No comments: