Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 Target Local server

Author  Topic 

AgaK
Yak Posting Veteran

86 Posts

Posted - 2010-01-04 : 11:07:58
Hi,

I am creating a job with sp_creat_job. How do I set the Target Local server automatically?

Thank you

AK

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-01-04 : 13:01:04
You should be using sp_add_job, which doesn't have that as an input parameter. You can right-click on a job to see the create script. That's what I do when I want to script out jobs. It's a pain to do it from scratch.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

AgaK
Yak Posting Veteran

86 Posts

Posted - 2010-01-04 : 14:20:02
Hi

Thank you for your reply!

This is exactly what I did, I scripted the job. The sp_add_job contains the following parameter: @category_name=N'[Uncategorized (Local)]' but for some reason 'Target local server' remains unchecked. The [Uncategorized (Local)] category exists.

Cheers!

AK
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-01-04 : 15:05:24
What do you mean by "remains unchecked"?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

AgaK
Yak Posting Veteran

86 Posts

Posted - 2010-01-04 : 15:39:58
The radio button on the Targets tab in the job is unchecked. I can't run the job until I check it. Thank you!
Go to Top of Page

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2010-01-04 : 15:46:34
Did you also do sp_add_jobserver?

http://msdn.microsoft.com/en-us/library/ms178625.aspx
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-01-04 : 15:48:56
The @category_name is unrelated to that. Show us the T-SQL script for your job so that we can compare it to a working job.

It would be easiest if you created the job through the GUI, scripted that job out, and then compared it to your script to see what's different.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

Peter99
Constraint Violating Yak Guru

498 Posts

Posted - 2010-01-06 : 16:47:08
EXEC @ReturnCode = msdb.dbo.sp_add_jobserver @job_id = @jobId, @server_name = N'(local)'
Go to Top of Page

AgaK
Yak Posting Veteran

86 Posts

Posted - 2010-01-07 : 18:47:17
That works! Thank you very much!
Go to Top of Page
   

- Advertisement -