Hi Everyone,
I have a quick question. I currently have a SQL trigger that send out an email to the users alerting them when a new record has been add/updated on a table. This work great I ran into a problem where the trigger is starting to interfere with another application. Is it possible to setup a T-SQL script to send out this alert at the end of the day? If yes, how can this be accomplish?
Below is my current sql trigger.
Thanks..
CREATE TRIGGER [New_Check] ON [dbo].[_fed820_Header] FOR INSERT, UPDATE AS Declare @checkno as varchar(12) Declare @totalcheck as varchar(12) Declare @checkdate as varchar(12) Declare @batchno as varchar(20) Declare @stControlNo as varchar(20) Declare @payer as varchar(20) SET @checkno = (Select checkno from inserted) SET @totalcheck = (Select totalcheck from inserted) SET @checkdate = (Select checkdate from inserted) SET @batchno = (Select batchno from inserted) SET @StControlNo = (Select STControlNo from inserted) SET @Payer = (Select Payer from inserted) Declare @Msg as Varchar(500) Set @Msg='Visit http://xxxxxxxxxx.com/ Report # 13 for Detail.' + char(13) + char(10) + 'From: ' + @Payer + char(13) + char(10) + 'Check#: ' + @checkno + char(13) + char(10) + 'Batch No: ' + @batchno + char(13) + char(10) + 'Control No: ' + @stControlNo + char(13) + char(10) + 'Check Date: ' + Convert(varchar,convert(datetime, @checkdate),101) + char(13) + char(10) + 'Check Total: $'+ CONVERT(varchar, CONVERT(money, @TotalCheck), 1) Declare @Subj as Varchar(500) Set @Subj ='Macys Check Received -New/Revised - Check # ' + @Checkno + ' Date: ' + Convert(varchar,convert(datetime, @checkdate),101) + ' Amount: $'+ CONVERT(varchar, CONVERT(money, @TotalCheck), 1) exec master..xp_startmail exec master..xp_sendmail @recipients='rob@xxxxxx.com;' , @message=@Msg, @copy_recipients='xxxx_it@xxxx.com;', @subject=@Subj exec master..xp_stopmail