A convenient way to move or copy database files is to detach and attach databases. Detaching database files removes the database from an instance of SQL Server but leaves the database files intact. After the database is detached, the files associated with the database (that is,
.ldf files) can be copied or moved to an alternate location. You can then reattach the relocated files by using the
CREATE DATABASE command with the
FOR ATTACH option.
The process of detaching and attaching a database is extremely fast. It is therefore a good alternative to use
RESTORE when you’re copying a database to another location. The catch with detaching a database is that all users must be disconnected ...