Guest User

Untitled

a guest
May 25th, 2018
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.17 KB | None | 0 0
  1. USE [FSNEPv2]
  2. GO
  3. /****** Object: StoredProcedure [dbo].[usp_NotifyUsersOfSemiAnnualCertification] Script Date: 05/12/2010 10:47:47 ******/
  4. SET ANSI_NULLS ON
  5. GO
  6. SET QUOTED_IDENTIFIER ON
  7. GO
  8.  
  9. ALTER Procedure [dbo].[usp_NotifyUsersOfSemiAnnualCertification]
  10.  
  11. AS
  12.  
  13. DECLARE @dayInt int
  14. DECLARE @monthInt int
  15.  
  16. SET @dayInt = (SELECT DATEPART(DAY, GETDATE()))
  17. SET @monthInt = (SELECT DATEPART(month, GETDATE()))
  18.  
  19. IF (@dayInt = 13) AND (@monthInt = 4 OR @monthInt = 1)
  20. BEGIN
  21.  
  22. DECLARE @MailList CURSOR
  23. SET @MailList = CURSOR FOR
  24.  
  25. --Get all of the 1.0 FTE TimeSheet Users
  26. SELECT aspnet_Membership.Email, Users.FirstName + ' ' + Users.LastName as FullName
  27. FROM aspnet_Membership INNER JOIN
  28. aspnet_UsersInRoles ON aspnet_Membership.UserId = aspnet_UsersInRoles.UserId INNER JOIN
  29. aspnet_Roles ON aspnet_UsersInRoles.RoleId = aspnet_Roles.RoleId AND aspnet_UsersInRoles.RoleId = aspnet_Roles.RoleId INNER JOIN
  30. Users ON aspnet_Membership.UserId = Users.UserId
  31. WHERE (aspnet_Roles.RoleName = N'Timesheet User') AND (FTE = 1)
  32.  
  33. OPEN @MailList
  34.  
  35. DECLARE @Email varchar(50), @FullName varchar(100)
  36. FETCH NEXT FROM @MailList INTO @Email, @FullName
  37.  
  38. WHILE (@@FETCH_STATUS = 0)
  39. BEGIN
  40. --Send emails to each matching user
  41. DECLARE @bodyText varchar(MAX)
  42.  
  43. SET @bodyText = 'This email was generated by the FSNEP Online Time Record System.
  44. *** Please do not respond to this email address ***
  45.  
  46. This is a reminder that your FSNEP Semi-Annual Certification record is due by the 15th of this month. Please print and then complete the attached certification and obtain the necessary signatures and dates. Send a PDF copy of the certification to your State Office Analyst by the 15th of the month.
  47.  
  48. If you have any questions regarding this message, or about time records in general, please contact your State Office analyst:
  49.  
  50. Corinne Gould ( cgould@ucdavis.edu ) or
  51. Susan Padgett ( sdpadgett@ucdavis.edu ) or
  52. Yolanda Cortez (yCortez@ucdavis.edu ).
  53. '
  54.  
  55. EXEC msdb.dbo.sp_send_dbmail
  56. @recipients=@Email,
  57. @subject='UC-FSNEP Semi-Annual Certification Record Due',
  58. @body=@bodyText
  59.  
  60. FETCH NEXT FROM @MailList INTO @Email, @FullName
  61. END
  62.  
  63. CLOSE @MailList
  64. DEALLOCATE @MailList
  65.  
  66. END
Add Comment
Please, Sign In to add comment