SQL Server: Take Database Offline and Online

3/20/2013 12:00:22 AM

How to take a db offline and back on again with SQL.

-- Take Offline
ALTER DATABASE [MyDatabase] SET OFFLINE WITH ROLLBACK IMMEDIATE
GO

-- Put Online
ALTER DATABASE [MyDatabase] SET ONLINE
GO