insert into PendingEmails (Subject,Body,ToEmail,PendingEmailStatusID)
select REPLACE( select subject from dbo.EmailTemplates where ID = 7 ), '[CallID]'), (select Body from dbo.EmailTemplates where ID = 7) ,contact.Email ,5
FROM inserted AS i inner join Calls on i.CallID = Calls.CallId inner join Contact on calls.ContactID = Contact.ContactID
where contact.Email is not null and contact.Email <> ''
I want to replace ‘[CallID]’ in the subject with a value. that syntax is not working.
I also tried using a variable, wont work either.
What is the best way to do that?
I can’t see where you are joining to the call table to get calls.callid, have you already stored it into a variable?
You can skip the variable if you have a subquery that will produce it (bracket the scalar subquery)
Or JOIN it