Advertisement
Guest User

Untitled

a guest
Nov 20th, 2013
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 0.94 KB | None | 0 0
  1. declare
  2. @out_desc nvarchar(max),
  3. @out_mesg nvarchar(50)
  4. declare @ref nvarchar(50),
  5. @next date
  6. declare c1 cursor read_only
  7. for
  8. select [calibration_no], [description], [next_calibration]
  9. from calibration.dbo.item
  10. open c1
  11. fetch next from c1 into
  12. @ref, @next
  13. while @@fetch_status = 0
  14. begin
  15. if datepart(month,@next) <= dateadd(month, 1, (datepart(month, getdate())))
  16. begin
  17. exec calibration.dbo.spSendMail @recipients = 'xxxxxxxx',
  18. @subject = 'Test Email',
  19. @from = 'xxxxxxxx',  
  20. @body = 'Item number ' + STR(@ref) + 'is due calibration on ' + STR(convert(nvarchar(20), @next))
  21. + '. <br><br>Please take the necessary action to ensure the item is calibrated before this time.
  22. <br><br>You can view the item here > http://server/app/ViewItem.aspx?calibration_no=' + STR(@ref)
  23. @output_mesg = @out_mesg output,
  24. @output_desc = @out_desc output
  25. print @out_mesg
  26. print @out_desc
  27. end
  28. fetch next from c1 into
  29. @ref, @next
  30. end
  31. close c1
  32. deallocate c1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement