Friday, May 14, 2010

Useful SQL commands during the database mirroring / log shipping

ALTER DATABASE TESTDB SET
SINGLE_USER WITH Rollback Immediate
Go

/****** Object: Database [TESTDB] Script Date: 05/12/2010 14:21:21 ******/
CREATE DATABASE [TESTDB_SS] ON PRIMARY
( NAME = N'TESTDB', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10.SDC\MSSQL\DATA\TESTDB.ss' )
AS SNAPSHOT OF TESTDB
GO

ALTER DATABASE testdb SET PARTNER FORCE_SERVICE_ALLOW_DATA_LOSS;
GO