Sql – MS SQL Server restoring database from MDF & LDF not showing latest data

sql server

The database is MS SQL Server Express 2005. The database is in simple mode.

I am trying to restore an existing database to a new server. I copied the MDF and LDF files to a new server. I attached the MDF and verified that the correct LDF was associated with it. After attaching the database, I compared the data from both databases and found that the new attached data was not current. Why?

Best Answer

  • Detach the database.
  • Copy the MDF and LDF files
  • Reattach on new server

I'm surprised you managed to copy the files at first because SQL Server locks the files exclusively.

You need to detach to cleanly "shut down" the database.