472,358 Members | 1,935 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,358 software developers and data experts.

Script to stop a SQL service

Is there a script that I can run to stop a particular SQL server service on
Win2003 server? I'm looking for a similar script to restart that service as
well. Thanks.
Jul 23 '05 #1
5 27106
NET START <service>
NET STOP <service>

If you have a default instance install of SQL Server 200: "NET START
MSSQLSERVER"

Regards
--------------------------------
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland

IM: mi**@epprecht.net

MVP Program: http://www.microsoft.com/mvp

Blog: http://www.msmvps.com/epprecht/

"Paul O. Morris" <po******@comcast.net> wrote in message
news:K8********************@comcast.com...
Is there a script that I can run to stop a particular SQL server service
on Win2003 server? I'm looking for a similar script to restart that
service as well. Thanks.

Jul 23 '05 #2
You can use the NET STOP and NET START commands from the command-prompt to
stop/start any Windows service. For a default SQL Server instance:

NET STOP MSSQLSERVER
NET START MSSQLSERVER

For a named instance:

NET STOP MSSQL$MyInstance
NET START MSSQL$MyInstance

You can also use SQL-DMO to stop/start a SQL Server instance. VbScript
Examples:

'stop example
Option Explicit
Dim oSQLServer
Set oSQLServer = CreateObject("SQLDMO.SQLServer")
oSQLServer.Name = "MyServer"
oSQLServer.Stop

'start example
Option Explicit
Dim oSQLServer
Set oSQLServer = CreateObject("SQLDMO.SQLServer")
oSQLServer.Start False, "MyServer"

--
Hope this helps.

Dan Guzman
SQL Server MVP

"Paul O. Morris" <po******@comcast.net> wrote in message
news:K8********************@comcast.com...
Is there a script that I can run to stop a particular SQL server service
on Win2003 server? I'm looking for a similar script to restart that
service as well. Thanks.

Jul 23 '05 #3
Would the syntax be the same if I ran the command line script from within a
batch file?

I'm planning on running this batch file from within the BackUp Exec
software. I have two database programs that run SQL services, preventing
the backup jobs from doing a thorough job. Automatically shutting down
those SQL services will allow jobs to complete properly.
"Dan Guzman" <gu******@nospam-online.sbcglobal.net> wrote in message
news:Bl****************@newssvr30.news.prodigy.com ...
You can use the NET STOP and NET START commands from the command-prompt to
stop/start any Windows service. For a default SQL Server instance:

NET STOP MSSQLSERVER
NET START MSSQLSERVER

For a named instance:

NET STOP MSSQL$MyInstance
NET START MSSQL$MyInstance

You can also use SQL-DMO to stop/start a SQL Server instance. VbScript
Examples:

'stop example
Option Explicit
Dim oSQLServer
Set oSQLServer = CreateObject("SQLDMO.SQLServer")
oSQLServer.Name = "MyServer"
oSQLServer.Stop

'start example
Option Explicit
Dim oSQLServer
Set oSQLServer = CreateObject("SQLDMO.SQLServer")
oSQLServer.Start False, "MyServer"

--
Hope this helps.

Dan Guzman
SQL Server MVP

"Paul O. Morris" <po******@comcast.net> wrote in message
news:K8********************@comcast.com...
Is there a script that I can run to stop a particular SQL server service
on Win2003 server? I'm looking for a similar script to restart that
service as well. Thanks.


Jul 23 '05 #4
> Would the syntax be the same if I ran the command line script from within
a batch file?
Yes.
I'm planning on running this batch file from within the BackUp Exec
software. I have two database programs that run SQL services, preventing
the backup jobs from doing a thorough job. Automatically shutting down
those SQL services will allow jobs to complete properly.
Rather than cold backups, consider backing up your databases to disk using
Transact-SQL BACKUP DATABASE and then archiving the disk backup files to
tape using your backup software. This allows you to perform backups while
the databases are online and uses less tape storage. Many backup vendors
also provide a specialized backup agent for SQL Server that allows you to
backup SQL Server databases online.

In any case, be sure to thoroughly test your recovery procedure.

--
Hope this helps.

Dan Guzman
SQL Server MVP

"Paul O. Morris" <po******@comcast.net> wrote in message
news:Y_********************@comcast.com... Would the syntax be the same if I ran the command line script from within
a batch file?

I'm planning on running this batch file from within the BackUp Exec
software. I have two database programs that run SQL services, preventing
the backup jobs from doing a thorough job. Automatically shutting down
those SQL services will allow jobs to complete properly.
"Dan Guzman" <gu******@nospam-online.sbcglobal.net> wrote in message
news:Bl****************@newssvr30.news.prodigy.com ...
You can use the NET STOP and NET START commands from the command-prompt
to stop/start any Windows service. For a default SQL Server instance:

NET STOP MSSQLSERVER
NET START MSSQLSERVER

For a named instance:

NET STOP MSSQL$MyInstance
NET START MSSQL$MyInstance

You can also use SQL-DMO to stop/start a SQL Server instance. VbScript
Examples:

'stop example
Option Explicit
Dim oSQLServer
Set oSQLServer = CreateObject("SQLDMO.SQLServer")
oSQLServer.Name = "MyServer"
oSQLServer.Stop

'start example
Option Explicit
Dim oSQLServer
Set oSQLServer = CreateObject("SQLDMO.SQLServer")
oSQLServer.Start False, "MyServer"

--
Hope this helps.

Dan Guzman
SQL Server MVP

"Paul O. Morris" <po******@comcast.net> wrote in message
news:K8********************@comcast.com...
Is there a script that I can run to stop a particular SQL server service
on Win2003 server? I'm looking for a similar script to restart that
service as well. Thanks.



Jul 23 '05 #5
Thanks, guys. I'll give it a shot.
"Dan Guzman" <gu******@nospam-online.sbcglobal.net> wrote in message
news:zO*****************@newssvr30.news.prodigy.co m...
Would the syntax be the same if I ran the command line script from within
a batch file?


Yes.
I'm planning on running this batch file from within the BackUp Exec
software. I have two database programs that run SQL services, preventing
the backup jobs from doing a thorough job. Automatically shutting down
those SQL services will allow jobs to complete properly.


Rather than cold backups, consider backing up your databases to disk using
Transact-SQL BACKUP DATABASE and then archiving the disk backup files to
tape using your backup software. This allows you to perform backups while
the databases are online and uses less tape storage. Many backup vendors
also provide a specialized backup agent for SQL Server that allows you to
backup SQL Server databases online.

In any case, be sure to thoroughly test your recovery procedure.

--
Hope this helps.

Dan Guzman
SQL Server MVP

"Paul O. Morris" <po******@comcast.net> wrote in message
news:Y_********************@comcast.com...
Would the syntax be the same if I ran the command line script from within
a batch file?

I'm planning on running this batch file from within the BackUp Exec
software. I have two database programs that run SQL services, preventing
the backup jobs from doing a thorough job. Automatically shutting down
those SQL services will allow jobs to complete properly.
"Dan Guzman" <gu******@nospam-online.sbcglobal.net> wrote in message
news:Bl****************@newssvr30.news.prodigy.com ...
You can use the NET STOP and NET START commands from the command-prompt
to stop/start any Windows service. For a default SQL Server instance:

NET STOP MSSQLSERVER
NET START MSSQLSERVER

For a named instance:

NET STOP MSSQL$MyInstance
NET START MSSQL$MyInstance

You can also use SQL-DMO to stop/start a SQL Server instance. VbScript
Examples:

'stop example
Option Explicit
Dim oSQLServer
Set oSQLServer = CreateObject("SQLDMO.SQLServer")
oSQLServer.Name = "MyServer"
oSQLServer.Stop

'start example
Option Explicit
Dim oSQLServer
Set oSQLServer = CreateObject("SQLDMO.SQLServer")
oSQLServer.Start False, "MyServer"

--
Hope this helps.

Dan Guzman
SQL Server MVP

"Paul O. Morris" <po******@comcast.net> wrote in message
news:K8********************@comcast.com...
Is there a script that I can run to stop a particular SQL server
service on Win2003 server? I'm looking for a similar script to restart
that service as well. Thanks.



Jul 23 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Peter Steele | last post by:
Okay, I assume I'm missing something obvious here. I have created a simple service in C# that on starting spawns a thread to do some processing. The service can be stopped with a "net stop" command...
2
by: Prasad | last post by:
Hi, I am writing a service which takes a long time to stop after the OnStop call is given by the Services Snap-in. The problem is I cannot cut down on the time that it takes to Stop. The Service...
6
by: Jacobus Terhorst | last post by:
Using C#: I tried: ServiceController me = new ServiceController(this.ServiceName); me.Stop(); it raises an exception: Cannot find Service I also tried:
7
by: Timo Haberkern | last post by:
Hi there, i have some troubles with my TSearch2 Installation. I have done this installation as described in http://www.sai.msu.su/~megera/oddmuse/index.cgi/Tsearch_V2_compound_words...
2
by: ANarula | last post by:
I am running into a strange problem. I have perl script which reads the "APPDATA" environment variable, and does some work on that directory. When I a launch this script from Command Prompt, it...
7
by: shai | last post by:
I am working at .net 1.1, writing in c#. I have windows service with a COM object. Every unexpected time The COM object throw an error that make my service get stuck (do not respond). I can catch...
3
by: rsteph | last post by:
I have a script that shows the time and date. It's been working on my site for quite a while now. Suddenly it stops showing up, after getting my drop down menu to work. If I put text between the...
0
by: mattcfisher | last post by:
Hi, I have two windows services running together. One is the main program, and one is an "updater" wrapper for the main. The updater service starts and stops the main one (as in you should never...
1
by: Aspersieman | last post by:
Hi All I have a windows service (attached file). I basically just calls another script every 60 seconds. I can install, start and stop this service as expected with: ParseMailboxService.py...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
1
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. header("Location:".$urlback); Is this the right layout the...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it so the python app could use a http request to get...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.