SQL Server TSQL – Take a database offline and online

by , under SQL Server

— Create Test DB
CREATE DATABASE [DBName]
GO
— Take the Database Offline
ALTER DATABASE [DBName] SET OFFLINE WITH ROLLBACK IMMEDIATE
GO
— Take the Database Online
ALTER DATABASE [DBName] SET ONLINE
GO
— Clean up
DROP DATABASE [DBName]
GO

 

Leave a Reply