Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sp_add_job syntax error 1

Status
Not open for further replies.

thamms

MIS
Sep 13, 2007
44
ZA
Hi,

Why doesn't this work:

CREATE PROCEDURE myProc @JobName NVARCHAR(400)
AS
BEGIN
EXEC sp_add_job
@job_name = @JobName, --@JobName is a parameter
@delete_level = 0
END

Error message:
Cannot add rows to sysdepends for the current object because it depends on the missing object 'sp_add_job'. The object will still be created.

Thanks
 
Try it like this:

Code:
CREATE PROCEDURE myProc @JobName NVARCHAR(400)
AS
BEGIN
EXEC msdb.dbo.sp_add_job 
   @job_name = @JobName, --@JobName is a parameter
   @delete_level = 0
END

-------------------------------------------------------------------------------------------------------------------------
"Now I can look at you in peace; I don't eat you any more." Franz Kafka, while admiring fish in an aquarium
 
I agree with PatriciaObreja, you need to at least state the object owner dbo or your created dboaccount. If you are running the command outside of the context of the database then you will have to use database.databaseowner.object.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top