October 31, 2016 at 8:29 am
Hi,
I'm trying to send returned results of a query only if something is returned back in the query through the sp_send_dbmail function..
I've tried to use the following but it doesn't seem to be working.....
IF EXISTS (SELECT [QUERY HERE])
BEGIN
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'Adventure Works Administrator',
@recipients = 'yourfriend@Adventure-Works.com',
@subject = 'Test',
@attach_query_result_as_file = 0 ;
end
any ideas ?
October 31, 2016 at 8:39 am
Suth (10/31/2016)
Hi,I'm trying to send returned results of a query only if something is returned back in the query through the sp_send_dbmail function..
I've tried to use the following but it doesn't seem to be working.....
IF EXISTS (SELECT [QUERY HERE])
BEGIN
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'Adventure Works Administrator',
@recipients = 'yourfriend@Adventure-Works.com',
@subject = 'Test',
@attach_query_result_as_file = 0 ;
end
any ideas ?
'Not working'. Is that all of the information you are prepared to give us?
Is there an error message?
Does the statement work if you issue it unconditionally?
If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.
October 31, 2016 at 8:42 am
You'll also need to use parameter "@query = " when calling the sp_send_dbmail procedure. Look in BOL for a complete list of parameters.
October 31, 2016 at 10:34 am
Question now is, what the hell happened to my post which included code to do this (or maybe this is a duplicate post)? I'll see if I saved the example somewhere and try to repost it tonight.
--Jeff Moden
Change is inevitable... Change for the better is not.
October 31, 2016 at 10:46 am
Deleted.
If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply