The recommended way to transfer a database is with backup/restore. This article is kept for historical purposes only.

How do you “Attach” a database to SQL server?

Follow these steps (as Administrator):

  • Copy the .mdf/.ldf files to a local drive on the SQL Server machine
  • Open a SQL query window from SQL Server Management Studio Express (SSMS)
  • sp_attach_db 'AceMapper','c:\db\AceMapper.mdf','c:\db\AceMapper.ldf'

Change the path names for the last command as necessary. You may need to right-click and run SSMS as Administrator.

⚠️Note: for performance reasons, it is often a good idea to put the mdf and ldf on separate disks.

Revised: 2016-10-10