How to execute Sql Server Agent job from Trigger

if you want to trigger the job on database insert,update and delete operation then you want to write the trigger in the way below:


CREATE TRIGGER TriggerName
ON TableName
AFTER INSERT, UPDATE, DELETE
AS
EXEC msdb..sp_start_job
@job_name = 'JobName';
GO

you need to only replace 'JobName' with your create job.



Cheers...

No comments:

Post a Comment