简体   繁体   中英

Move database from SQL Server 2008 Express to SQL Server 2012

We are looking at migrating one of our databases from SQL Server 2008 Express to SQL Server 2012. The guy that has been taking care of the database says he always does a detach, copy the files to the new server and attach. This takes the database offline of course.

Is there a benefit in doing that vs. right click backup, copy backup files and right click restore on the new server?

Taking a backup should pull everything without taking the DB offline correct?

Is there a recommended best practice for this?

(New to the MS database world)

You could Backup and Restore

You will still have to "un-orphan" sql-users to db-users.

BACKUP DATABASE MyDB TO DISK = 'c:\backups\MyDB.bak' WITH FORMAT

RESTORE DATABASE MyDB FROM DISK = 'c:\backups\MyDB.bak' WITH REPLACE, 
MOVE 'MyDB' TO 'd:\sqlfiles\mydb.mdf',
MOVE 'MyDB_Log' TO 'd:\sqlfiles\mydb_log.ldf'

Change the paths however you want.

I'm not sure about best practice, but I have done this more times than I can remember and never had an issue by backing up the DB, taking the old DB offline, and restoring the backup to the new server.

I guess on really high traffic systems you may want to take the DB offline first to ensure nothing changes during your backing up (new records added etc. which would be lost). If you take the DB offline first then you can't back up the DB, so I guess that's when attaching the individual files to the new server becomes necessary as opposed to just restoring the backup.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM