[sql]代码库
SET NOCOUNT OFF
DECLARE @jobID UNIQUEIDENTIFIER --variable for job_id
DECLARE planidCursor CURSOR FOR --used for cursor allocation
SELECT job_id FROM msdb.dbo.sysjobs WHERE enabled=1
OPEN planidCursor
FETCH NEXT FROM planidCursor INTO @jobID
WHILE @@Fetch_Status = 0
BEGIN
--disable SQL Server Agent Job - @enabled parameter value is 0, enabled parameter value is 1
EXEC msdb.dbo.sp_update_job @job_id=@jobID, @enabled = 0
FETCH Next FROM planidCursor INTO @jobID
END
CLOSE planidCursor
DEALLOCATE planidCursor