0

hi every one,
iam a newbie in .net,i have a application in which i have to send email using triggers.can any one plz help, on how to configure sql mail .my application needs to delete rows on completion of expiry date and send the administrator email notifying it.
ok waiting for reply
bye

2
Contributors
3
Replies
4
Views
10 Years
Discussion Span
Last Post by greeny_1984
0

hi,
i want to elaborate wat exactly i want.trigger executes only after update or insert or delete occurs.i want to know how to delete rows even if the administrator didnt update or insert or didnt touch the datebase for few days,then aslo we should be able to delete rows and mails should be sent notifying the administrator about deleting rows.

0

my code is like this
CREATE TRIGGER [trg_job] ON [dbo].[JobPost]
FOR INSERT, UPDATE, DELETE
AS
set nocount on
declare @msg varchar(2000),
@postingdate nvarchar(50),
@applydays nvarchar(30),
@jobexpirydate nvarchar(30)
declare email_cur CURSOR
for
select postingdate,applydays,jobexpirydate from jobpost
where jobexpirydate = dateadd(dd, 2,getdate())
open email_cur
fetch next from email_cur into @postingdate, @applydays, @jobexpirydate
while @@Fetch_status=0
begin
set @msg='Dear row will be deleted'
exec master.dbo.xp_sendmail @recipients='xxx@yyy.com', @message=@msg,
@subject='delete Notification'
fetch next from email_cur into @postingdate, @applydays, @jobexpirydate
end
deallocate email_cur

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.