Changing Job Owner


While I was about to leave from office, I received a mail from one of our customer to change the Job Owner details for 20 different jobs in four different instances. Although I prefer to use the GUI, but this time I prefer to use t-sql script to complete the assigned task because I don’t want to click the mouse buttons so many times. 😉

With a little search on Books Online, I found the script which I was looking for. There is a system stored procedure, sp_update_job, which does the exact thing, what I was looking for. The first required parameter for this stored procedure is either the Job ID or the Job Name. A lot of different attributes of a job can be modified by using the above stored procedure. As I had to modify the Job Owner Details, I used the following piece of code:

USE [msdb];
GO
EXEC msdb.dbo.sp_update_job @job_name = 'Testjob 12', @owner_login_name = 'skg\skganguly';
GO

For a complete list of attributes supported by this stored procedure, refer this article. With this SP, I was able to complete the task within 10 minutes. I found this script very helpful, so thought of documenting it. Hope, you will find it useful.

Advertisements

About Sudeepta Ganguly

A SQL Server User... Still Learning
This entry was posted in How To, Jobs, Just Learned, SQL Server and tagged , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s