Pass parameters to sql agent job step (Transact-SQL Script)

3k views Asked by At

I have created a sql agent job consisting on one job step of type Transact-SQL Script(T-SQL) and i'm using command as EXEC STORED_PROC

Is there any way to pass parameters to stored procedure above?

1

There are 1 answers

0
Mahesh Kumar On

To add the job into the agent the basic command would be this...

sp_add_job @job_name = "Job Name"

Now, if you know the parameter series; say for example if @Startdate is the 1st param and @EndDate is the 2nd param. Just follow this, it'll work.

DECLARE @JobName_With_Params AS VARCHAR(50) SET @JobName_With_Params = ‘JobName 1/1/2008 2/2/2008’ sp_add_job @job_name = @JobName_With_Params

There are remaining paramter to be passed for this system SP. Check this link for the rest of the parameters http://doc.ddart.net/mssql/sql70/sp_adda_13.htm