Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««12

E-Mail notifications occurring on success despite configuration in job Expand / Collapse
Author
Message
Posted Wednesday, February 19, 2014 6:04 PM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Tuesday, August 26, 2014 6:36 AM
Points: 76, Visits: 168
Hello --

I went to the job in question, and in the Properties window, I went to Notifications. The settings are the following:

E-Mail <Operator> When job fails
Post #1543300
Posted Wednesday, February 19, 2014 7:30 PM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: 2 days ago @ 10:38 PM
Points: 3,931, Visits: 7,160
Script out the jobs you are having issues with and post them here. There has to be some TSQL script sending the email...

______________________________________________________________________________
"Never argue with an idiot; They'll drag you down to their level and beat you with experience"
Post #1543309
Posted Thursday, February 20, 2014 7:19 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Tuesday, August 26, 2014 6:36 AM
Points: 76, Visits: 168
Per your request, I am posting the T-SQL scripts for the job in question:

Taken from the Maintenance Plan -> Backups -> Subplan_3
BACKUP LOG [RayStationClinicDB_25189] TO DISK = N'T:\BACKUP_25\RayStationClinicDB_25189_backup_2014_02_20_091754_5984039.trn' WITH RETAINDAYS = 2, NOFORMAT, NOINIT, NAME = N'RayStationClinicDB_25189_backup_2014_02_20_091754_5984039', SKIP, REWIND, NOUNLOAD, STATS = 10
GO
BACKUP LOG [RayStationMachineDB_25189] TO DISK = N'T:\BACKUP_25\RayStationMachineDB_25189_backup_2014_02_20_091754_6044045.trn' WITH RETAINDAYS = 2, NOFORMAT, NOINIT, NAME = N'RayStationMachineDB_25189_backup_2014_02_20_091754_6044045', SKIP, REWIND, NOUNLOAD, STATS = 10
GO
BACKUP LOG [RayStationPatientDB_25189] TO DISK = N'T:\BACKUP_25\RayStationPatientDB_25189_backup_2014_02_20_091754_6094050.trn' WITH RETAINDAYS = 2, NOFORMAT, NOINIT, NAME = N'RayStationPatientDB_25189_backup_2014_02_20_091754_6094050', SKIP, REWIND, NOUNLOAD, STATS = 10


Taken from the Job Step Properties under the SQL Agent -> Jobs -> Transaction Logs Backups
/SQL "Maintenance Plans\RayStation 25 Backups" /SERVER "MGHROSTORAGE2\RAYCLINICAL" /CHECKPOINTING OFF /SET "\Package\Subplan_3.Disable";false /REPORTING E


Post #1543477
Posted Thursday, February 20, 2014 7:28 AM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: 2 days ago @ 10:38 PM
Points: 3,931, Visits: 7,160
This isn't what I meant. This is the maintenance plan's "auto-generated" code.

Try opening SSMS, on the server this all runs on expand the (+) for the SQL Server Agent, expand the (+) for Jobs, find your job in the list, then right-click, choose "Script Job as ->", then choose "Create to ->", then "New Query Editor Window".

This will give you a script for the actual job (which will include all the TSQL for everything the jobs does, for example:
USE [msdb]
GO

/****** Object: Job [DBA - Check for Long Running Jobs] Script Date: 02/20/2014 08:26:40 ******/
BEGIN TRANSACTION
D ECLARE @ReturnCode INT
SELECT @ReturnCode = 0
/****** Object: JobCategory [Database Maintenance] Script Date: 02/20/2014 08:26:40 ******/
IF NOT EXISTS (SELECT name FROM msdb.dbo.syscategories WHERE name=N'Database Maintenance' AND category_class=1)
BEGIN
EXEC @ReturnCode = msdb.dbo.sp_add_category @class=N'JOB', @type=N'LOCAL', @name=N'Database Maintenance'
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback

END

DECLARE @jobId BINARY(16)
EXEC @ReturnCode = msdb.dbo.sp_add_job @job_name=N'DBA - Check for Long Running Jobs',
@enabled=1,
@notify_level_eventlog=2,
@notify_level_email=2,
@notify_level_netsend=0,
@notify_level_page=0,
@delete_level=0,
@description=N'01/14/2011 - MDJ - Created to be used by DBA''s to monitor whatever is needed i.e. (failed jobs, long running jobs, general maintenance, etx)',
@category_name=N'Database Maintenance',
@owner_login_name=N'sa',
@notify_email_operator_name=N'DBA', @job_id = @jobId OUTPUT
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
/****** Object: Step [Check for Long Running Jobs] Script Date: 02/20/2014 08:26:40 ******/
EXEC @ReturnCode = msdb.dbo.sp_add_jobstep @job_id=@jobId, @step_name=N'Check for Long Running Jobs',
@step_id=1,
@cmdexec_success_code=0,
@on_success_action=1,
@on_success_step_id=0,
@on_fail_action=2,
@on_fail_step_id=0,
@retry_attempts=0,
@retry_interval=0,
@os_run_priority=0, @subsystem=N'TSQL',
@command=N'/* Last parameter denites time in minutes that job will check for */
exec utl_dba_CheckLongRunningAgentJobs 1, ''mydoggiejessie@company.com'', 300',
@database_name=N'F1Settings',
@flags=0
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
EXEC @ReturnCode = msdb.dbo.sp_update_job @job_id = @jobId, @start_step_id = 1
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
EXEC @ReturnCode = msdb.dbo.sp_add_jobschedule @job_id=@jobId, @name=N'Hourly',
@enabled=1,
@freq_type=4,
@freq_interval=1,
@freq_subday_type=8,
@freq_subday_interval=1,
@freq_relative_interval=0,
@freq_recurrence_factor=0,
@active_start_date=20110114,
@active_end_date=99991231,
@active_start_time=0,
@active_end_time=235959,
@schedule_uid=N'0129162e-527e-4a58-a6be-50e5e4871b8d'
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
EXEC @ReturnCode = msdb.dbo.sp_add_jobserver @job_id = @jobId, @server_name = N'(local)'
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
COMMIT TRANSACTION
GOTO EndSave
QuitWithRollback:
IF (@@TRANCOUNT > 0) ROLLBACK TRANSACTION
EndSave:

GO





______________________________________________________________________________
"Never argue with an idiot; They'll drag you down to their level and beat you with experience"
Post #1543487
Posted Thursday, February 20, 2014 7:52 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Tuesday, August 26, 2014 6:36 AM
Points: 76, Visits: 168
Let's try this again:

USE [msdb]
GO

/****** Object: Job [RayStation 25 Transaction Log Backup] Script Date: 02/20/2014 09:50:30 ******/
BEGIN TRANSACTION
DECLARE @ReturnCode INT
SELECT @ReturnCode = 0
/****** Object: JobCategory [Database Maintenance] Script Date: 02/20/2014 09:50:31 ******/
IF NOT EXISTS (SELECT name FROM msdb.dbo.syscategories WHERE name=N'Database Maintenance' AND category_class=1)
BEGIN
EXEC @ReturnCode = msdb.dbo.sp_add_category @class=N'JOB', @type=N'LOCAL', @name=N'Database Maintenance'
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback

END

DECLARE @jobId BINARY(16)
EXEC @ReturnCode = msdb.dbo.sp_add_job @job_name=N'RayStation 25 Transaction Log Backup',
@enabled=1,
@notify_level_eventlog=2,
@notify_level_email=2,
@notify_level_netsend=0,
@notify_level_page=0,
@delete_level=0,
@description=N'No description available.',
@category_name=N'Database Maintenance',
@owner_login_name=N'sa',
@notify_email_operator_name=N'RODB Admins', @job_id = @jobId OUTPUT
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
/****** Object: Step [Subplan_3] Script Date: 02/20/2014 09:50:31 ******/
EXEC @ReturnCode = msdb.dbo.sp_add_jobstep @job_id=@jobId, @step_name=N'Subplan_3',
@step_id=1,
@cmdexec_success_code=0,
@on_success_action=1,
@on_success_step_id=0,
@on_fail_action=2,
@on_fail_step_id=0,
@retry_attempts=0,
@retry_interval=0,
@os_run_priority=0, @subsystem=N'SSIS',
@command=N'/Server "$(ESCAPE_NONE(SRVR))" /SQL "Maintenance Plans\RayStation 25 Backups" /set "\Package\Subplan_3.Disable;false"',
@flags=0
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
EXEC @ReturnCode = msdb.dbo.sp_update_job @job_id = @jobId, @start_step_id = 1
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
EXEC @ReturnCode = msdb.dbo.sp_add_jobschedule @job_id=@jobId, @name=N'RayStation 25 Backups.Subplan_3',
@enabled=1,
@freq_type=4,
@freq_interval=1,
@freq_subday_type=8,
@freq_subday_interval=1,
@freq_relative_interval=0,
@freq_recurrence_factor=0,
@active_start_date=20130207,
@active_end_date=99991231,
@active_start_time=0,
@active_end_time=235959,
@schedule_uid=N'58caf469-8f71-44af-b9a8-9dca11cc85d4'
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
EXEC @ReturnCode = msdb.dbo.sp_add_jobserver @job_id = @jobId, @server_name = N'(local)'
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
COMMIT TRANSACTION
GOTO EndSave
QuitWithRollback:
IF (@@TRANCOUNT > 0) ROLLBACK TRANSACTION
EndSave:

GO

Post #1543511
Posted Thursday, February 20, 2014 7:59 AM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: 2 days ago @ 10:38 PM
Points: 3,931, Visits: 7,160
Ok, thanks for this, and it confirms there is nothing specific set in your Agent job that is sending the email. So go back to the maintenance plan and add the Notify Operator/Email tasks, set it up using the instructions I originally posted (with the constraints set) - this should send an email only when there is an error.

______________________________________________________________________________
"Never argue with an idiot; They'll drag you down to their level and beat you with experience"
Post #1543515
Posted Wednesday, March 5, 2014 7:56 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Tuesday, August 26, 2014 6:36 AM
Points: 76, Visits: 168
Hi --

My apologies for my late response. I went ahead with your suggestion, and it worked. Thanks again for the help.
Post #1547806
Posted Wednesday, March 5, 2014 8:36 AM


SSCrazy Eights

SSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy Eights

Group: General Forum Members
Last Login: Thursday, June 5, 2014 10:54 AM
Points: 9,294, Visits: 9,480
Oops, sorry. Posted in error, please ignore...


-- RBarryYoung, (302)375-0451 blog: MovingSQL.com, Twitter: @RBarryYoung
Proactive Performance Solutions, Inc.
"Performance is our middle name."
Post #1547847
Posted Wednesday, March 5, 2014 8:44 AM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: 2 days ago @ 10:38 PM
Points: 3,931, Visits: 7,160
Glad to hear that!

______________________________________________________________________________
"Never argue with an idiot; They'll drag you down to their level and beat you with experience"
Post #1547851
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse