Quick and Easy way to email results - if any

  • 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.

  • 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

  • good , you found it on your own.

    Regards
    Durai Nagarajan

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply