x

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]
 AS
 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'
 
 else
                     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

Gehima2016
1 2

(comments are locked)
10|1200 characters needed characters left

1 answer: sort voted first

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

more ▼

answered Jan 15 at 04:33 AM

avatar image

Jeff Moden
2.3k 3 7 13

(comments are locked)
10|1200 characters needed characters left
Your answer
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

By RSS:

Answers

Answers and Comments

SQL Server Central

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

Topics:

x19
x10

asked: Jan 10 at 06:31 PM

Seen: 27 times

Last Updated: Jan 15 at 04:33 AM

Copyright 2018 Redgate Software. Privacy Policy