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?
The absence of evidence is not evidence of absence
- Martin Rees
The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
- Phil Parkin
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.
The absence of evidence is not evidence of absence
- Martin Rees
The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
- Phil Parkin
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply