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 |
mpowell80
Starting Member
2 Posts |
Posted - 2012-11-29 : 14:17:47
|
When I run the query on it's own, the appropriate record list is returned, 7 in all. However, when the mail sends through only one of the notification records from the list is displayed. What am I missing? ALTER PROCEDURE [dbo].[spGNGNotifications] @OpportunityID varchar(32), @Name varchar(255)ASDECLARE @NotificationMessage varchar(max), @Notification varchar(max) DECLARE GetNotification CURSOR FOR SELECT NotificationMessage FROM [gsp].[funGSP_GetGoNoGoNotifications]('E59E14B384194CD79C8C024CE7321D3B')OPEN GetNotificationFETCH NEXT FROM GetNotificationINTO @NotificationWHILE @@FETCH_STATUS = 0BEGINPRINT @NotificationFETCH NEXT FROM GetNotificationINTO @NotificationENDSET @NotificationMessage = @NotificationCLOSE GetNotificationDEALLOCATE GetNotification --EXECUTE as USER = 'me' exec msdb.dbo.sp_send_dbmail @profile_name = 'SQL Mail', @recipients ='me@me.com', @subject = 'New Opportunity', @body = @NotificationMessage, @body_format = 'html'Melissa |
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
mpowell80
Starting Member
2 Posts |
Posted - 2012-11-29 : 15:35:00
|
Thank you, Tara.I moved the email portion above the ending and then received all the results, but they were in separate emails and I would like them presented all in one email together. I tried SET @NotificationMessage = @NotificationMessage + @Notification, and then the emails came through blank. Any ideas? I Appreciate your reply!SET @NotificationMessage = @Notification--EXECUTE as USER = 'me'exec msdb.dbo.sp_send_dbmail@profile_name = 'SQL Mail',@recipients ='me@me.com',@subject = 'New Opportunity',@body = @NotificationMessage,@body_format = 'html'ENDCLOSE GetNotificationDEALLOCATE GetNotificationMelissa |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
|
|
|
|