When you run it gives message, "Job 'YourJobName' started successfully." On second run, if first request is in queue, it will return with the following message, "Msg 22022, Level 16, State 1, Line 0 SQLServerAgent Error: Request to run job YourJobName (from User sa) refused because the job already has a pending request from User sa."
USE MSDB
GO
DECLARE @JobName VARCHAR(100)
SET @JobName = 'YourJobName'
EXEC MSDB.DBO.Sp_start_job @JobName --You can also invoke with JobId
GO
Wednesday, 3 June 2015
Invoke Scheduled Job on demand in SQL Server by serverku
We are mostly scheduled the job for the any script, but I have prepared the SP which invoked Job on demand as required, below code which I have created by SP and called it from the UI.
Labels:
schedule jobs,
script,
short notes,
SQL,
SQL Server
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Please Use Good Leanguage