October 21, 2004 at 1:15 pm
On one of our databases we have a table on which data in appended whenever we have a problem in that database. Normally we check the table from time to time to look for addition of data. But I would like to create a trigger to notify a user (net send operator) on our network whenever data is inserted into this table. Is this possible???
October 21, 2004 at 1:31 pm
Yes this is possible.
You could get it notify users by using xp_sendmail or the stored procedure i provided the link for in answer to your previous post or you could use xp_cmdshell to send a net send.
As you say anything that is inserted into the table is an error it is a very easy trigger to write e.g.
CREATE TRIGGER ti_Asset_Inserted ON [dbo].[LINESTK]
AFTER INSERT
AS
exec master..xp_sendmail @recipients = 'arg@fluff.com;kwi@fluff.com;dthomo@fluff.com',
@message = @MailMessage,
@subject = 'New item added to stock database', @no_output = TRUE
etc etc depending on how you choose to do it.
Hope this helps
Dave
October 21, 2004 at 2:48 pm
That sounds perfect. If I wanted to use the xp_cmdshell for a net send instead of the xp_sendmail using e-mail, is there anything I would have to change in the script?
October 21, 2004 at 3:12 pm
No you would just replace the mail stuff with
exec master..xp_cmdshell 'net send ....... '
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy