Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 shutdown & Restart SQL server 2005

Author  Topic 

Surajit
Starting Member

5 Posts

Posted - 2009-05-28 : 05:58:49
Hi,

Can u tell me what is the best way to shutdown and restart SQL server.

Is it possible to do this by query?Please help.

Regards,
Surajit

Surajit Mukherjee

savior faire
Posting Yak Master

194 Posts

Posted - 2009-05-28 : 07:17:23
Check Books Online to see if this can be done with some sort of command line script.

Talk sense to a fool and he calls you foolish.
Go to Top of Page

savior faire
Posting Yak Master

194 Posts

Posted - 2009-05-28 : 08:58:20
By happenstance, I just stumbled across a method to do this just a few minutes ago. Talk about coincidences. Hope this helps.

http://sqlblogcasts.com/blogs/jorg/archive/2009/01/06/start-stop-sql-server-ssis-ssas-ssrs-and-sql-server-agent-at-once-with-a-batch-file.aspx

Talk sense to a fool and he calls you foolish.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-05-28 : 09:16:36
You can use SSMS to do this.
Right click the server node in Object explorer and choose restart.



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

savior faire
Posting Yak Master

194 Posts

Posted - 2009-05-28 : 09:44:07
Peso, I believe the poster is looking for an automated way to do this on some sort of schedule.

Talk sense to a fool and he calls you foolish.
Go to Top of Page

Surajit
Starting Member

5 Posts

Posted - 2009-05-29 : 02:00:45
Savior,This is through batch file and i am aware of this.I want to shutdown/restart the server's instance from query in a time when i want to do the same.Do we have any way in SQL server for this?

Surajit Mukherjee
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-05-29 : 03:48:36
in your bat file, write

net stop mssqlserver
net start mssqlserver



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

dmaxj
Posting Yak Master

174 Posts

Posted - 2011-02-15 : 12:01:20
Is there anyway to determine the SQL Server instance names from the command line - just in case 'mssqlserver' is not the default?
Go to Top of Page

dmaxj
Posting Yak Master

174 Posts

Posted - 2011-02-15 : 13:12:25
Perhaps, I should clarify -

Is there a way to assign SQL Server instance name(s) to command line argument(s)?
Go to Top of Page

dmaxj
Posting Yak Master

174 Posts

Posted - 2011-02-15 : 16:05:03
So, I have come across being able to use the following code, with hopes of just extracting the InstanceName:

C:>SQLCMD -Q "SELECT SERVERPROPERTY('InstanceName')"

In theory, this should work but, I only get lots of blank lines, dashes and (1 rows affected) with a NULL at the end.

Any clues on why I am not getting the instance name?
Go to Top of Page

jeffw8713
Aged Yak Warrior

819 Posts

Posted - 2011-02-15 : 16:30:30
You can easily shutdown SQL Server from a query. Lookup the SHUTDOWN command in books online.

However, once SQL Server is shut down there is no way to connect to the instance to restart it. You have to issue the start command from a command line, the services applet or configuration manager.

Jeff
Go to Top of Page

dmaxj
Posting Yak Master

174 Posts

Posted - 2011-02-15 : 21:51:26
jeffw8713, the prob is about extracting the sql service instance name from cmd line...

no java or any other layers - thank you.

Go to Top of Page

jeffw8713
Aged Yak Warrior

819 Posts

Posted - 2011-02-16 : 16:52:34
@dmaxj - I was not responding to your request, but now I see that you started a new topic on an existing old thread.

I apologize for answering the original question that was asked...

Jeff
Go to Top of Page
   

- Advertisement -