Cari Blog Ini

09 Desember 2013

How To Start or Stop Services SQL Server Agent

Apply To :
* Microsoft SQL Server 2008 R2
* Microsoft Windows Server 2008 Standard


Problem : 

* Want to start or stop services of SQL Server Agent
* Using Command Prompt or File System Object
* Create schedulling task







Solution :

1. Example of SQL Server Services





2. Try to run syntax start or stop Services of SQL Server using Command Prompt Windows



Then, type "CMD". And choose "OK"




A.
To stop Services of SQL Server Agent, type this :
net stop "SQL Server Agent (MSSQLSERVER)"
MSSQLSERVER = is instancename.





B.
To stop Services SQL Server, type this :
net stop "SQL Server (MSSQLSERVER)"
MSSQLSERVER = is instancename.





C.
To start Services of SQL Server Agent, type this :
net start "SQL Server Agent (MSSQLSERVER)"
MSSQLSERVER = is instancename.





3.
If want create a schedulling of Start or Services,

A. Open a new file Notepad, then type the below code

'-----------------------------------------------------
'-----------------------------------------------------
'-----CODE START


dim objFSO, objoutputFile

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objoutputFile = objFSO.CreateTextFile("Script_Restart_Services_Bat.bat")


objoutputFile.writeline "net stop ""SQL SERVER Agent (MSSQLSERVER)"" "
objoutputFile.writeline "net stop ""SQL SERVER (MSSQLSERVER)"" "
objoutputFile.writeline "net start ""SQL SERVER Agent (MSSQLSERVER)"" "

objoutputFile.close

'-----CODE END
'-----------------------------------------------------
'-----------------------------------------------------








C.
Next, Do double-click file name "Script_Restart_Services.VBS"
and automatically will create file name "Script_Restart_Services"_Bat.bat"




D.
Create a task scheduler





Source :
* http://technet.microsoft.com/en-us/library/ms175192%28v=sql.105%29.aspx
* http://technet.microsoft.com/en-us/library/ms187008%28v=SQL.105%29.aspx


About :
* How To Create Task Scheduler in Windows Server