Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Quick and Easy way to email results - if any Expand / Collapse
Author
Message
Posted Monday, May 20, 2013 2:41 PM
Say Hey Kid

Say Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey Kid

Group: General Forum Members
Last Login: 2 days ago @ 7:31 AM
Points: 706, Visits: 1,752
Hi,

I have this little query:

Select deddedcode, dedlongDesc, deddatetimecreated from dedcode where deddatetimecreated > DATEADD(DAY, DATEDIFF(DAY, 0, GETDATE()), -1)

I would like the results emailed to one person, but only if there are results (some days there won't be any new codes).

What's the easiest way to accomplish this?

It doesn't need to be a fancy report, plain text is fine.



Post #1454739
Posted Monday, May 20, 2013 2:48 PM
Say Hey Kid

Say Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey Kid

Group: General Forum Members
Last Login: 2 days ago @ 7:31 AM
Points: 706, Visits: 1,752
found a way...thanks anyway guys..

IF (select count(*) from [e009]) > 0
begin

exec msdb.dbo.sp_send_dbmail
@profile_name = 'Default',
@recipients = 'me@example.com',
@subject = 'warning',
@query = 'select * from [e009]',
@attach_query_result_as_file = 1,
@query_attachment_filename = 'warning.csv'

end




Post #1454744
Posted Monday, May 20, 2013 11:11 PM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Friday, May 30, 2014 8:15 AM
Points: 1,056, Visits: 2,687
good , you found it on your own.

Regards
Durai Nagarajan
Post #1454816
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse