Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 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.4k 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

Welcome to Intellipaat Community. Get your technical queries answered by top developers!

28.4k questions

29.7k answers

500 comments

94.1k users

Browse Categories

...