November 21, 2006 at 4:02 am
I have created a Stored Procedure to autostart SQL Server agent when SQL Server starts.
The stored proc is
CREATE PROC AutoStart_SQLAgent
AS
BEGIN
DECLARE @Err int, @Msg varchar(100), @ServiceName sysname
SET @ServiceName = 'SQLServerAgent'
EXEC master.dbo.xp_servicecontrol 'START', @ServiceName
SET @Err = @@ERROR
IF @Err = 0
BEGIN
RAISERROR ('Successfully started SQL Server Agent', 1, 1) WITH LOG
END
ELSE
BEGIN
SET @Msg = 'Error occured while starting SQL Server Agent. Error code: ' + STR(@Err)
RAISERROR (@Msg, 18, 1) WITH LOG
END
END
GO
EXEC sp_procoption 'AutoStart_SQLAgent', 'startup', 'true'
GO
The procedure has been successfully created and when i executed , the error is
StartService() returned error 5, 'Access is denied.'
Successfully started SQL Server Agent
Msg 50000, Level 1, State 1
Any body knows the solution ,Pls help me.
Thanks
Nirmala
November 21, 2006 at 4:37 am
I'd say that your SQL Server account does not have permissions to start services. Under what account are you running the MSSQLSERVER (or similar) service?
November 21, 2006 at 5:52 am
Thanks for responding.
I think SQLServer account is, Network Service account (NT AUTHORITY\NetworkService).
If this would be the problem, what should i do to resolve it. Pls helpme.
Once again thanks,
Nirmala
November 21, 2006 at 9:03 am
You need to get privilege to do it. Or you may ask sa to do it.
You can simply check the proper checkbox in the properties of your SQL Server.
November 21, 2006 at 12:43 pm
Why are you doing this? Just set the SQL Server Agent service to automatically start. It's dependent on the SQL Server service, so the agent one won't start until the main one does.
-SQLBill
November 21, 2006 at 10:02 pm
Thanks for your reply.
May i know whick checkboxes have to be enabled and could u explain in detail.
Thanks
Nirmala
November 21, 2006 at 11:27 pm
I think you need to check the user's with DB mappings.
THanks,
S Suresh
November 22, 2006 at 12:03 pm
Here's how to do it from Enterprise Manger if you have the access privileges:
November 22, 2006 at 2:31 pm
Michael,
Autostart in that context only occurs when the server is started. Then SQL Server Agent will autostart.
I believe the poster's problem is that when you just stop the services (MSSQLServer and SQLServerAgent); restarting MSSQLServer does not start SQLServerAgent. You must manually restart SQLServerAgent. However, if you start SQLServerAgent, it will start MSSQLServer since it depends on that service.
But as I said, you must do that manually unless you are restarting your server or you have figured out a script to start it.
-SQLBill
November 22, 2006 at 10:07 pm
Hi
I need to autostart the SQLServer Agent thro script(shown in earlier post) and i get error.
Also i couldn't able to find the option "Autostart SQL Agent" what u have mentioned in your post. Iam using SQLServer 2005 and i work in SQLserver management studio.What i should do to solve the problem.
Thanks
Nirmala
Viewing 10 posts - 1 through 9 (of 9 total)
You must be logged in to reply to this topic. Login to reply