     delete from workflow
     from workflow w inner join @cteTmpRev r on w.workflowId = r.workflowId
 END
-
+')
 GO
 
 IF OBJECT_ID ('trigger_job_delete','TR') IS NOT NULL
     DROP TRIGGER trigger_job_delete;
 GO
 
-CREATE TRIGGER trigger_job_delete
+exec('CREATE TRIGGER trigger_job_delete
 ON job
 INSTEAD OF DELETE
 AS

  host_id BIGINT NULL,      -- unlike most host_id columns, this one allows NULLs because the request can be at the service level
  PRIMARY KEY CLUSTERED (operation_level_id)
  );

CREATE TABLE ClusterHostMapping (
  cluster_id BIGINT NOT NULL,
  host_id BIGINT NOT NULL,


    delete from job
    from job j inner join deleted d on j.jobId = d.jobId
END')

GO

