Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
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
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Tuesday, April 26, 2016 6:47 AM
Points: 833, Visits: 2,272
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
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Tuesday, April 26, 2016 6:47 AM
Points: 833, Visits: 2,272
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, March 18, 2016 4:25 AM
Points: 1,061, Visits: 2,713
good , you found it on your own.

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

Add to briefcase

Permissions Expand / Collapse