I am executing a job from command line (sqlcmd).
EXEC msdb.dbo.sp_start_job @job_name = @job_name
How can I pass a parameter at the time of job execution through the command line.
I am executing a job from command line (sqlcmd).
EXEC msdb.dbo.sp_start_job @job_name = @job_name
How can I pass a parameter at the time of job execution through the command line.
There is not direct way to pass parameter to "msdb.dbo.sp_start_job"
So we can think indirect way to do something.
You could create a table to hold the parameters, such as:
CREATE TABLE SQLAgentJobParms
(job_id uniqueidentifier,
groupparm int,
parameter_name nvarchar(100),
parameter_value nvarchar(100),
used_datetime datetime NULL);
The groupparm is way to identify a group of parameters intended to go together. One you have used them you can update the used_datetime.
You would then need to write your job to select the necessary values from this table in order to use them as parameters for the steps in your job.
EXEC sp_start_job