467,149 Members | 1,269 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,149 developers. It's quick & easy.

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
  • viewed: 26639
Share:
5 Replies
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Peter Steele | last post: by
6 posts views Thread by Jacobus Terhorst | last post: by
reply views Thread by mattcfisher@gmail.com | last post: by
1 post views Thread by Aspersieman | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.