Posted on Leave a comment

TSQL to control SQL Server Agent

To Start the sql server agent,
EXEC master.dbo.xp_ServiceControl ‘START’, ‘SQLServerAgent’

To Stop the sql server agent,
EXEC master.dbo.xp_ServiceControl ‘STOP’, ‘SQLServerAgent’

To Check the status of the sql server agent,
EXEC master.dbo.xp_ServiceControl ‘QueryState’, ‘SQLServerAgent’

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.