May 19, 2004 at 1:24 pm
I need to restart a database through SQL statement.
What is the SQL statement which I can use for this purpose. I am planning to execute this in SQL Query Analyzer.
Thanks
Krishna:
May 19, 2004 at 1:46 pm
What exactly do you mean by restart a database? Do you mean to kill all current connections to leave it "clean"? Detach a database and reattach it? Set the database offline and then online again? Or to restart an entire instance?
What are you looking to accomplish?
May 20, 2004 at 11:55 am
I was trying to schedule for a restore of my database. Before that I am stopping connections to the database from Web server. When I am executing the SQL for Restore, it is failing due to the database connections are not refreshed. when I restarted the database manually and Restored it is working. So, I need SQL statement for Restarting the database through query.
I hope you have understood my requirement.
Thanks,
Krishna
May 20, 2004 at 11:55 am
I was trying to schedule for a restore of my database. Before that I am stopping connections to the database from Web server. When I am executing the SQL for Restore, it is failing due to the database connections are not refreshed. when I restarted the database manually and Restored it is working. So, I need SQL statement for Restarting the database through query.
I hope you have understood my requirement.
Thanks,
Krishna
May 20, 2004 at 12:03 pm
Rather than restarting you would be better served by setting the database into single user mode before attempting the restore and then resetting it back to multi user mode afterwards...
--Before the restore
USE master
GO
ALTER DATABASE
SET SINGLE_USER
--After the restore
USE master
GO
ALTER DATABASE
SET MULTI_USER
Viewing 5 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply