July 20, 2004 at 1:15 am
How to autostart SQL Server Agent using SQL command.
July 20, 2004 at 5:37 am
As far as I can tell you cannot start it via native SQL commands. Did find this in BOL
The sqlagent application starts SQL Server Agent from the command prompt. Usually, SQL Server Agent should be run from SQL Server Service Manager or by using SQL-DMO methods in an application. Only run sqlagent from the command prompt when you are diagnosing SQL Server Agent, or when you are directed to by your primary support provider.
sqlagent -c [-v]
-c
Indicates that SQL Server Agent is running from the command prompt and is independent of the Windows NT Service Control Manager. When -c is used, SQL Server Agent cannot be controlled from either the Services application in Control Panel or SQL Server Service Manager.
-v
Indicates that SQL Server Agent runs in verbose mode and writes diagnostic information to the command-prompt window. The diagnostic information is the same as the information written to the SQL Server Agent error log.
After displaying a copyright message, sqlagent displays output in the command prompt window only when the -v switch is specified. To stop sqlagent, press CTRL+C at the command prompt. Do not close the command-prompt window before stopping sqlagent.
For information about where to find or how to run this utility, see Getting Started with Command Prompt Utilities.
If you do want to start it via SQL you will have to use SHELL and research sc.exe or net start, etc..
Good Hunting!
AJ Ahrens
webmaster@kritter.net
July 21, 2004 at 3:45 am
Hi AJ Ahrens,
Thanks for the reply. Now i'm using "net start SQLServerAgent" command to start the SQL Server Agent. it' is working.
Harikrishna
July 30, 2004 at 9:38 am
EXEC master.dbo.xp_servicecontrol 'start', 'SQLServerAgent'
August 2, 2004 at 6:16 am
Hi gbn,
Thnax very much for the idea.
Hari
August 10, 2005 at 7:15 pm
I know this is a really old thread, but I haven't found the answer anywhere else online.
Here's how you programmatically change the autostart option for your SQL Server Agent.
EXEC msdb.dbo.sp_set_sqlagent_properties @auto_start = 1
This will change the START registry entry at HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SQLSERVERAGENT.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply