Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
sz1
Aged Yak Warrior
555 Posts |
Posted - 2013-10-22 : 06:53:32
|
Hi,Is it possible to send the query results with an email command? rather than setup a Stored Procedure?ThanksUse TestGOSELECT p.[ProblemNumber], COUNT(i.[IncidentNumber]) as ActiveIncidentsFROM [Problem] p JOIN [Incident] i ON P.[RecID] = i.[ProblemRecID]WHERE p.[Status] <> 'Closed' AND i.[Status] = 'Active'GROUP BY p.[ProblemNumber]Use msdbGoEXEC sp_send_dbmail @profile_name='ITServices',@recipients='itservices@mycomp.co.uk',@subject='Active Incidents',@body='Active Incidents Attached to Problems.',@importance = 'High'SZ1Please help me to enable me to help others! |
|
sz1
Aged Yak Warrior
555 Posts |
Posted - 2013-10-22 : 07:25:29
|
Sorted it with this script.EXEC sp_send_dbmail @profile_name='ITServices',@recipients='itservices@mycomp.co.uk',@subject='Active Incidents',@body='Active Incidents Attached to Problems.',@importance = 'High',@query = 'Use TestGoSELECT p.[ProblemNumber], COUNT(i.[IncidentNumber]) as ActiveIncidents FROM [Problem] p JOIN [Incident] i ON P.[RecID] = i.[ProblemRecID] WHERE p.[Status] <> ''Closed'' AND i.[Status] = ''Active'' GROUP BY p.[ProblemNumber]', @attach_query_result_as_file = 0;SZ1Please help me to enable me to help others! |
|
|
|
|
|
|
|