SQL SERVER 只有MDF文件的恢复

方式一:

1.create a database same name as .mdf file; 

2.Stop SQL Server;  

3. recover .mdf file; 

4. Start SQL Server, the DB will be suspect;

5. Run the following SQL for the DB

ALTER DATABASE yourdb SET EMERGENCY;

ALTER DATABASE yourdb SET SINGLE_USER;

DBCC CHECKDB (yourdb, REPAIR_ALLOW_DATA_LOSS) ;

ALTER DATABASE yourdb SET MULTI_USER;

ALTER DATABASE yourdb SET ONLINE

 

I try the steps on MSSQL 2008 ,the last three SQL never success at the step 5. but you can read the tables on the database.so,you can export records to another database.

 

方式二:

 EXEC sp_attach_single_file_db @dbname = 'jyhangye2', 

@physname = 'D:\Program files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\jyhangye2.mdf' 

 

@dbname:恢复的数据库名   
@physname:物理文件位置 
 

你可能感兴趣的:(SQL Server)