t-sql script to start & stop SQLAgent

  • Hi,

    Is there any way to stop & Start SQL Server & SQLAgent using t-sql commands?

    thanks

  • execute xp_cmdshell 'net stop sqlserveragent'

    execute xp_cmdshell 'net start sqlserveragent'

    -Vikas Bindra

  • I have written a script which checks whether sql agent is running and then starts sql agent if its not. You can also do the same using SP_Configure and the net start commands.

    SP_Configure is used to enable xp_cmdshell command. Its a simple stored procedure which is configured to run during startup.

    Come back here if you have any doubts.

    "Keep Trying"

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply