Tuesday, May 4, 2010

Take DataBase Offline and Online in SQL Server

Its a very tiny script for taking database offline and online.

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

ref: Pinal Dave

No comments:

Post a Comment