declare @pra varchar(100)=' '
declare c1 cursor for
select emailid from tbl_emp
where not exists(select emailid from tbl_remainder where ryear=year(getdate()))
and datediff(DAY,GETDATE(),jdate)<=14 and datediff(DAY,GETDATE(),jdate)>0
open c1
fetch next from c1 into @pra
while(@@FETCH_STATUS=0)
begin
exec msdb.dbo.sp_send_dbmail @profile_name='gmail',@subject='MAIL ALERT',
@body='Hai Sir',
@recipients=@pra
insert into tbl_Remainder(emailid,RYear) values(@pra,year(GETDATE()))
fetch next from c1 into @pra
end
close c1
deallocate c1
declare c1 cursor for
select emailid from tbl_emp
where not exists(select emailid from tbl_remainder where ryear=year(getdate()))
and datediff(DAY,GETDATE(),jdate)<=14 and datediff(DAY,GETDATE(),jdate)>0
open c1
fetch next from c1 into @pra
while(@@FETCH_STATUS=0)
begin
exec msdb.dbo.sp_send_dbmail @profile_name='gmail',@subject='MAIL ALERT',
@body='Hai Sir',
@recipients=@pra
insert into tbl_Remainder(emailid,RYear) values(@pra,year(GETDATE()))
fetch next from c1 into @pra
end
close c1
deallocate c1
No comments:
Post a Comment