USE BurgoyneMusic GO Declare @Emails varchar(50) Select @Emails=@Emails + (a.Email) From Student As a Where exists (SELECT * From CreditCard As b WHERE a.StudentID = b.StudentID And b.CCMonth = month(DATEADD("m",-1,GETDATE())) And b.CCYear = DATEPART(year,GETDATE())) USE msdb EXEC sp_send_dbmail @profile_name='MyProfile', @recipients= @Emails, @subject='subject', @body='message body'
|why does some in the xx field return as null? Case statement||2||21|
|T-SQL--Two Different Totals Even with the Same Concept||6||45|
|T-SQL: What won't it just collapse? It would be the logical thing to do!||20||45|
|SQL Server merge records in one table||2||11|
Join the community of 500,000 technology professionals and ask your questions.
Connect with top rated Experts
16 Experts available now in Live!