Moving or copying a database

You might need to move a database before performing maintenance on your system, after a hardware failure, or when you replace your hardware with a newer, faster system. Copying a database is a common way to create a secondary development or testing environment. You can move or copy a database by using a technique called detach and attach or by backing up the database and restoring it in the new location.

Detaching and reattaching a database

You can detach a database from a server by using a simple stored procedure. Detaching a database requires that no one is using the database. If you find existing connections that you can’t terminate, you can use the ALTER DATABASE command and set the database to SINGLE_USER mode using ...

Get Microsoft SQL Server 2012 Internals now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.