July 25, 2011 at 4:45 am
hi can any give the code to restart services through code in SQL server 2005 and 2008
July 25, 2011 at 4:57 am
Well, you can shut SQL down from a SQL Agent job, but you won't be able to restart it. Stopping SQL Server stops SQL Agent.
You can use Windows Scheduler and the NET STOP and NET START commands.
Why do you need this? Restarting SQL is generally not something done so often that a scheduled task needs to be used.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
July 25, 2011 at 1:25 pm
I agree with Gila Monster but if you really need to you can create a .bat file and then set it up as a scheduled task.
NET STOP SQLSERVERAGENT
NET STOP MSSQLSERVER
NET START MSSQLSERVER
NET START SQLSERVERAGENT
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply