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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 SQL Insert/Update xp_sendmail a user the updated record

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2003-07-01 : 07:36:47
Shep writes "SQL Server 2000 MS Outlook 2000 Client:

When a user Inserts or Updates a new/exisiting record I want xp_sendmail to take the current values from that inserted/updated record and email it to somebody.

I first need to use one of the fields to get 2 unique identifiers (EID's) from the inserted record and then query a table to return that users email addresses. Then I need to send one user an email and have the reply to email populated by the other's email address.

Another monkey wrench is that I have relationships set up w/ primary and foreign keys in the table I want to send. Is there a way I can set up a trigger on a view (i have a view that populates all the right values)???? or is there a way to easily have the tbl insert the right text for the keyID?

This is the process flow:

Tech generates a record & database inserts --> Admin gets an email that there is a new record for them

Admin responds to record & database updates --> Tech gets email from the Admin saying that he updated and what was done.

And this can go on and on until the original record is approved by a check box.

This is currently how I am sending email on update & insert:
CREATE TRIGGER [EmailChange] ON [dbo].[tbl_Data]
FOR INSERT, UPDATE
AS
exec master.dbo.xp_sendmail 'person@email.com', 'message',"
   

- Advertisement -