SQL Server DB_mail sending multiple counts -


i using db_mail in sql server 2008 r 2 send counts of mail daily.

how can send 1 email daily has 3 counts ( count a, count b, count c) included?

you can use query multiple columns want.

  • [ @query = ] 'query'

    is query execute. the results of query can attached file, or included in body of e-mail message. query of type nvarchar(max), , can contain valid transact-sql statements. note query executed in separate session, local variables in script calling sp_send_dbmail not available query.

sample query:

exec msdb.dbo.sp_send_dbmail     @profile_name = 'adventure works administrator',     @recipients = 'danw@adventure-works.com',     @query = 'select count(*) counta, 1 countb, 2 countc                   adventureworks2012.production.workorder                   duedate > ''2004-04-30''                   ,  datediff(dd, ''2004-04-30'', duedate) < 2' ,     @subject = 'work order count',     @attach_query_result_as_file = 1 ; 

you can use variable set in body.


Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -