Stored Procedure development

I was assigned a task to automate a notification alert to inform managers to send checklist of terminated employee to security admin within 5 business days of effective termination of employee(s). Below is the stored procedure to be modified to perform this task. Please, I am baby developer. I need assistance as to developing the right code to do the job.

 CREATE PROCEDURE [dbo].[sp_TerminationChecklist]
 Declare @Rec_Count int  
 select @Rec_Count=count(*) from employee   
 where TerminationDate>dateadd(dd,-1,getdate())
 if @Rec_Count=0                                                                               
                     EXEC master.dbo.xp_sendmail                                                      
                    @recipients = 'TerminatedEmployeeManager', 
                    @message = 'There were no terminations for the previous workday',
                    @width =355,
                    @copy_recipients = 'aa12', 
                    @subject = ' DatabaseName - List of terminated employees',
                    @dbuse = 'DatabaseName'
                     EXEC master.dbo.xp_sendmail
                    @recipients = 'TerminatedEmployeeManager', 
                    @message = 'Please, send checklist of Terminated Employees to Security Admin with 5 day of effective termination of employee ',
            @query = 'select TerminationDate,EmpFirstName,
                                 EmpLastName,lanid from tblemployee
                                 where DateTerminated>dateadd(dd,-1,getdate())
                                 order by DateTerminated desc',
                    @width =355,
                    @copy_recipients = 'aa12', 
                    @subject = ' DatabaseName - List of terminated employees',
                    @dbuse = 'DatabaseName'
more ▼

asked Jan 10 at 06:31 PM in Default

avatar image

1 1 5

I guess I don't understand why you don't just send the terminations directly to the termination manager.

Jan 15 at 04:33 AM Jeff Moden
(comments are locked)
10|1200 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.



asked: Jan 10 at 06:31 PM

Seen: 47 times

Last Updated: Jan 15 at 04:33 AM

Copyright 2018 Redgate Software. Privacy Policy