Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
3.0 KiB

  1. -- Script generated on 5/14/2002 8:17 AM
  2. -- By: REDMOND\timragai
  3. -- Server: TKWUCDSQLA02
  4. BEGIN TRANSACTION
  5. DECLARE @JobID BINARY(16)
  6. DECLARE @ReturnCode INT
  7. SELECT @ReturnCode = 0
  8. IF (SELECT COUNT(*) FROM msdb.dbo.syscategories WHERE name = N'[Uncategorized (Local)]') < 1
  9. EXECUTE msdb.dbo.sp_add_category @name = N'[Uncategorized (Local)]'
  10. -- Delete the job with the same name (if it exists)
  11. SELECT @JobID = job_id
  12. FROM msdb.dbo.sysjobs
  13. WHERE (name = N'Mail Notifications')
  14. IF (@JobID IS NOT NULL)
  15. BEGIN
  16. -- Check if the job is a multi-server job
  17. IF (EXISTS (SELECT *
  18. FROM msdb.dbo.sysjobservers
  19. WHERE (job_id = @JobID) AND (server_id <> 0)))
  20. BEGIN
  21. -- There is, so abort the script
  22. RAISERROR (N'Unable to import job ''Mail Notifications'' since there is already a multi-server job with this name.', 16, 1)
  23. GOTO QuitWithRollback
  24. END
  25. ELSE
  26. -- Delete the [local] job
  27. EXECUTE msdb.dbo.sp_delete_job @job_name = N'Mail Notifications'
  28. SELECT @JobID = NULL
  29. END
  30. BEGIN
  31. -- Add the job
  32. EXECUTE @ReturnCode = msdb.dbo.sp_add_job @job_id = @JobID OUTPUT , @job_name = N'Mail Notifications', @owner_login_name = N'sa', @description = N'No description available.', @category_name = N'[Uncategorized (Local)]', @enabled = 1, @notify_level_email = 0, @notify_level_page = 0, @notify_level_netsend = 0, @notify_level_eventlog = 2, @delete_level= 0
  33. IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
  34. -- Add the job steps
  35. EXECUTE @ReturnCode = msdb.dbo.sp_add_jobstep @job_id = @JobID, @step_id = 1, @step_name = N'Send Mail', @command = N'cscript c:\follow.vbs', @database_name = N'', @server = N'', @database_user_name = N'', @subsystem = N'CmdExec', @cmdexec_success_code = 0, @flags = 0, @retry_attempts = 0, @retry_interval = 1, @output_file_name = N'', @on_success_step_id = 0, @on_success_action = 1, @on_fail_step_id = 0, @on_fail_action = 2
  36. IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
  37. EXECUTE @ReturnCode = msdb.dbo.sp_update_job @job_id = @JobID, @start_step_id = 1
  38. IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
  39. -- Add the job schedules
  40. EXECUTE @ReturnCode = msdb.dbo.sp_add_jobschedule @job_id = @JobID, @name = N'Email Time', @enabled = 1, @freq_type = 4, @active_start_date = 20020402, @active_start_time = 43000, @freq_interval = 1, @freq_subday_type = 1, @freq_subday_interval = 0, @freq_relative_interval = 0, @freq_recurrence_factor = 0, @active_end_date = 99991231, @active_end_time = 235959
  41. IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
  42. -- Add the Target Servers
  43. EXECUTE @ReturnCode = msdb.dbo.sp_add_jobserver @job_id = @JobID, @server_name = N'(local)'
  44. IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
  45. END
  46. COMMIT TRANSACTION
  47. GOTO EndSave
  48. QuitWithRollback:
  49. IF (@@TRANCOUNT > 0) ROLLBACK TRANSACTION
  50. EndSave: