Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
3 views
in SQL by (20.3k points)

How do I force my Database to go Offline, without regard to what or who is already using it?

I tried:

ALTER DATABASE database-name SET OFFLINE;

But it's still hanging after 7 min.

I want this because I need to test the scenario.

If it's even possible?

1 Answer

0 votes
by (40.7k points)

For offline use this query:

USE master

GO

ALTER DATABASE YourDatabaseName

SET OFFLINE WITH ROLLBACK IMMEDIATE

GO

For online use the below query:

USE master

GO

ALTER DATABASE YourDatabaseName

SET ONLINE

GO

...