News

Copyright © 2008-2018 Paula DiTallo

Tag Cloud



SQL Server: Why is it taking so long for SQL Server to take my database OFFLINE?

If you are using the SSMS GUI, you may not be aware that behind the scenes, you are really issuing an ALTER DATABSE command.  It is likely that another process (or processes) were accessing the database you want to take offline.

If you're a DBA, or have sysadmin privileges, issue an sp_who2 command -- looking for the ALTER DATABSE process logged to you.  Kill the process. 

Once the process has been killed off, issue the ALTER DATABSE command yourself.

To take the database offline:

USE master
GO

ALTER DATABASE yourDBname
SET OFFLINE WITH ROLLBACK IMMEDIATE
GO

To get the database back online:

USE master
GO

ALTER DATABASE yourDBname
SET ONLINE
GO

For added protection of data you do not wish to be online:

ALTER DATABASE yourDBname SET RESTRICTED_USER

Monday, September 14, 2015 7:35 AM

Feedback

No comments posted yet.


Post A Comment
Title:
Name:
Email:
Comment:
Verification: