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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Me again...

Author  Topic 

norty911
Starting Member

41 Posts

Posted - 2007-05-10 : 03:03:15
Hey guys, heres a another Q for you:

I have two tables: one table stores names and email addresses. The other table stores templated messages. The point of this system is to send predefined emails to certain users.

In the table that stores the templated messages, I have a column that obviously stores the actual email message.

The problem is I would like to email customized messages... So I would like to include information from the names table within THAT message. E.g. I want the message to say something like "Hello Skeletor you are reminded that...." where "Skeletor" is a name pulled from the names table.

Is there some sort of place holder or variable I can use within the messages column to hold the information pulled from the names table?

Thanks guys in advance for any help!

mwjdavidson
Aged Yak Warrior

735 Posts

Posted - 2007-05-10 : 03:27:36
You can use placeholders such as "[Fieldname]" and then use the REPLACE function to replace them with the relevant fields. I.e.
SELECT REPLACE(msg.MessageText, '[LastName]', cnt.LastName)
FROM dbo.MessageTemplates AS msg, dbo.Contacts AS cnt
-- where clause ... presumably you have criteria for the selection of contacts,
and an id or some such you can use to constrain to a particular message template


Mark
Go to Top of Page
   

- Advertisement -