Hey MikeI've done something like this in the past.I had a newsletter engine, but the client wanted to be able to choose the recipient list from some predetermined filters. Something like : User who have joined in the last month, or users from last year who haven't logged in for 6 months.For each of those filters, I wrote a proc to return the user id, first name, last name and email. Then my "Send Newsletter" proc had a parameter for the name of the required filter proc.I used that to grab the results of the filter proc and put it in a temp table, which i could then insert into my email queue table. The dynamic bit looked like this :Create Table #TempUser ( UserID int, FirstName varchar(100), LastName varchar(100), Email varchar(200) ) Declare @sql VarChar(4000)SET @SQL = 'INSERT #TempUser Exec ' + @FilterProcExec(@SQL)INSERT INTO MailQueue ( FromName, FromAddress, ToName, ToAddress, NewsletterID, UserID, Subject, Body)SELECT @FromName, @FromAddress, Firstname + ' ' + LastName, Email, NewsletterID, UserID, Headline, BodyFROM #TempUserINNER JOIN Newsletter N ON NewsletterID = @NewsletterIDDrop Table #TempUser
Hope that helpsDamian"A foolish consistency is the hobgoblin of little minds." - Emerson