1、把mdf文件和ldf文件拷贝到数据库的默认路径C:Program FilesMicrosoft SQL ServerMSSQL10.MSSQLSERVERMSSQLDATA里;
2、在sqlserver里新建个查询,执行下面代码;
USE master; GO CREATE DATABASE NewFile ON (FILENAME = 'C:Program FilesMicrosoft SQL ServerMSSQL10.MSSQLSERVERMSSQLDATAFile.mdf'), (FILENAME = 'C:Program FilesMicrosoft SQL ServerMSSQL10.MSSQLSERVERMSSQLDATAFile_log.ldf') FOR ATTACH; GO