Showing posts with label create sql jobs. move sql jobs. Show all posts
Showing posts with label create sql jobs. move sql jobs. Show all posts

Friday, June 17, 2016

SQL Agent Job: Update the notification operator

I found many SQL Agent job were enabled but no any  notifications setup in case of failure.

I ran the following

use msdb
GO
select * from dbo.sysjobs

where notify_level_email = 0

and enabled = 1

--- gives the list of jobs enabled but no notification set up.

SELECT [ID], [Name], [Enabled]

FROM MSDB.dbo.sysoperators

WHERE [Enabled] = 1

ORDER BY [Name];
Go

-- Gives the list of operators. Pick the Id of the one you want to notify to use in the below script








UPDATE S

SET S.[notify_level_email] = 2,

S.[notify_email_operator_id] = 2   ---my operator

FROM MSDB.dbo.sysjobs S

WHERE S.[Notify_Level_Email] = 0

AND S.[Enabled] = 1;




GO



Thursday, November 5, 2015

Work adventure : MoveSQL Agent Jobs to another instanse


It is very easy to move (recreate) the sql agent job that you want to export to another instance of SQL server

  1. Highlight the job you want o export
  2. Right click
  3. Choose Scrip Job as CREATE TO


The script is created and you can run that in the new instance that will create the job.

To move multiple jobs
You can also script multiple jobs to a single file. In SSMS

Click on Jobs,
hit F7 to get the 'Object Explorer Details' tab.
Highlight the jobs you want,
Script job as...