| Author |
Topic  |
|
|
kdeutsch
Yak Posting Veteran
USA
75 Posts |
Posted - 01/31/2013 : 11:26:56
|
I am tring to concantenate a string and send out less emails with multiple personnel in them. however my string never gets populated, its always empty when i look at it. so if I set this line like so . set @Receipt = @Email + ';'
Itgets a single email and populates just fine but I want to send multiple personnel per mail and change like so but nothing is concantanated. set @Receipt = @Receipt + @Email + ';'
Select @ii = COUNT(RowId) from #TempMail; set @i = 1; Set @Send = 1 While @i <= @ii BEGIN Select @Name = Name, @Email = Mail from #TempMail where Rowid = @i; IF @Send < 50 BEGIN set @Receipt = @Email + ';' print @Send print @Receipt END ELSE BEGIN --- do send the email here ... EXEC msdb.dbo.sp_send_dbmail @recipients = @Receipt, @body = @Body, @subject = @Subject, @profile_name = 'Testmail' Set @Send = 1; Set @Receipt = ''; END set @Send = (@Send + 1) set @i = (@i + 1); END Drop table #TempMail; END |
|
|
jackv
Flowing Fount of Yak Knowledge
United Kingdom
1769 Posts |
|
|
kdeutsch
Yak Posting Veteran
USA
75 Posts |
Posted - 02/01/2013 : 09:15:07
|
hi, Ok, I am using that as per my second paragraph but it still does not work, rather perplexed as to why this will not work. Dont want to send 1200 emails out of my sql server, would rather send out 20. |
 |
|
|
James K
Flowing Fount of Yak Knowledge
1490 Posts |
Posted - 02/01/2013 : 09:21:50
|
I see you have PRINT statements for @Send and @Receipt immediately after your concatenation statement. What are you seeing in the printed output? NULLS? If it is NULL, are you initializing @Receipt to something? If not, insert a statement at the very beginning, immediately after the declaration.SET @Receipt = ''; |
 |
|
| |
Topic  |
|