How to execute a SQL Job using script ?

 Posted by PandianS on 10/23/2010 | Category: Sql Server Interview questions | Views: 4745 | Points: 40
Answer:

DECLARE @JobID	VARCHAR(36), 

@retval INT

SELECT @JobID = Job_ID FROM msdb.dbo.sysjobs_view
WHERE [Name] = 'SQL Job Name'

EXEC @retval = msdb.dbo.sp_start_job @job_id = @JobID
GO


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response