USE [master] GO -- Method 1: I use this method EXEC sp_attach_single_file_db @dbname= 'TestDb' , @physname=N 'C:Program FilesMicrosoft SQL ServerMSSQL10.MSSQLSERVERMSSQLDATATestDb.mdf' GO -- Method 2: CREATE DATABASE TestDb ON (FILENAME = N 'C:Program FilesMicrosoft SQL ServerMSSQL10.MSSQLSERVERMSSQLDATATestDb.mdf' ) FOR ATTACH_REBUILD_LOG GO |
语句1就是将文件附加到数据库里,如果像我这种情况就会出现问题了。所以执行语句2就可以重新建立日志,管他几个日志文件。
-- Method 3: CREATE DATABASE TestDb ON ( FILENAME = N'C:Program FilesMicrosoft SQL ServerMSSQL10.MSSQLSERVERMSSQLDATATestDb.mdf') FOR ATTACH GO
再不行加上这个,基本全部解决,感谢上帝,否则就玩玩了!