ldf和mdf怎么还原sql2005数据

2024-11-08 04:55:34
推荐回答(1个)
回答(1):

1、把mdf文件和ldf文件拷贝到数据库的默认路径C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA里;
2、在sqlserver里新建个查询,执行下面代码;
1
2
3
4
5
6
7

USE master;
GO
CREATE DATABASE NewFile
ON (FILENAME = 'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\File.mdf'),
(FILENAME = 'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\File_log.ldf')
FOR ATTACH;
GO

3、刷新数据库,就出现了新的数据库NewFile;
根据mdf文件和ldf文件还原成功!