Trigger for warning delete and insert
1 answer
You need to configure dbmail in SqlServer 2005 (if you haven't already).
Inside the trigger, just send something like:
EXEC msdb.dbo.sp_send_dbmail
@recipients=N'me@address.com',
@subject=@sbj,
@blind_copy_recipients=N'you@address.com, himtoo@address.com',
@body=@Msg ;
Obviously fill in the variables - you can pull them out of the inserted data. Basic information about triggers is easy to find in BOL, we insert an insert using
(select * from inserted)
then assign variables like:
SELECT @Msg = MessageText, @Subject= Subject FROM Inserted
Where MessageText and Subject are columns in the inserted row. Just add your own variables for Location and ServerName if you like ...
+1
source to share