added files from swmgmt03
This commit is contained in:
28
EXPLOIT - start replication agents that are stopped.sql
Normal file
28
EXPLOIT - start replication agents that are stopped.sql
Normal file
@@ -0,0 +1,28 @@
|
||||
DECLARE @tpl VARCHAR(255)='exec [msdb].[dbo].[sp_start_job] @job_name= ''@job@''; '+CHAR(13)+CHAR(10)
|
||||
DECLARE @q VARCHAR(MAX)='';
|
||||
|
||||
WITH cteActivity AS (
|
||||
SELECT job_id, session_id, ROW_NUMBER()OVER(PARTITION BY job_id ORDER BY start_execution_date DESC) AS rnk
|
||||
FROM msdb.dbo.sysjobactivity
|
||||
)
|
||||
|
||||
SELECT @q = @q + REPLACE(@tpl, '@job@', j.name)
|
||||
FROM msdb.dbo.sysjobs j
|
||||
WHERE name LIKE 'ActivePosTran distribution agent -%'
|
||||
AND NOT EXISTS(
|
||||
--the job is currently running
|
||||
SELECT 1
|
||||
FROM msdb.dbo.sysjobactivity sja
|
||||
JOIN cteActivity ca ON ca.job_id = sja.job_id AND ca.session_id = sja.session_id
|
||||
WHERE sja.job_id = j.job_id
|
||||
AND ca.rnk=1
|
||||
AND sja.start_execution_date IS NOT NULL
|
||||
AND sja.stop_execution_date IS NULL
|
||||
)
|
||||
|
||||
IF NULLIF(@q,'') IS NOT NULL
|
||||
BEGIN
|
||||
PRINT @q
|
||||
select @q
|
||||
EXEC(@q)
|
||||
END
|
||||
Reference in New Issue
Block a user