DATETIME SELECT SELECT INTO DATE PAD STRING DYNAMIC SQL CURSOR MONEY FORMAT PERCENT STORED PROCEDURE SQL SERVER AGENT JOB OPTIMIZATION WHILE LOOP OVER PARTITION BY UPDATE
SITE SEARCH SQLUSA.com HEADLINES NEWS
SQL E/BOOKS   SQL 2014 PROGRAMMING   DOWNLOADS
SCRIPTS SQL 2005 SQL 2008 ARTICLES
SQL JOBS TWITTER FORMAT VIDEOS
How to email reports using xp_sendmail?

The following T-SQL system procedure samples demonstrate how to send query results (reports) to recepient(s):

EXEC msdb.dbo.sp_send_dbmail

    @profile_name = 'SQLDBEmail',

    @recipients = '[email protected]',

    @query = 'SELECT Color, Items=COUNT(*) FROM    AdventureWorks2008.Production.Product

                  GROUP BY Color ORDER BY Items DESC',

    @subject = 'Color usage in bike and related products',

    @attach_query_result_as_file = 1 ;

 

SQL Server 2000:

EXECUTE master.dbo.xp_sendmail
'[email protected]',
@query = 'select * from Orders where datediff(day, OrderDate,getdate())<30 order by RequiredDate ',
@no_header= 'FALSE',
@width = 72,
@dbuse = 'Northwind',
@subject= 'AutoNotice: Recent Orders',
@message='Orders for the last 30 days'

 


Exam Prep 70-461
Exam 70-461
DATETIME SELECT SELECT INTO DATE PAD STRING DYNAMIC SQL CURSOR MONEY FORMAT PERCENT STORED PROCEDURE SQL SERVER AGENT JOB OPTIMIZATION WHILE LOOP OVER PARTITION BY UPDATE