How to Detach a Database?

If you want to move a database from one server to another. This would be a quick method to do it.  I have given below the Query to detach a database:

USE master
GO
EXEC sp_detach_db ‘<Database Name>’

Advertisements

2 Responses to How to Detach a Database?

  1. madhivanan says:

    But note that this requires database to be offline and may not be suitable for 24/7 work environment. I prefer backup and restore

  2. Are you able to restore the backup without any downtime?. I have 20 databases in a database server. Just think about moving them into another server during the database server migration. Backup and Restore will take pretty much long down time. Even 24/7 will prefer to move the DBs in a very short period of time. Please reply me if I am wrong.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: