数据库
首页 > 数据库> > ldf和mdf文件怎么还原到sqlserver数据库

ldf和mdf文件怎么还原到sqlserver数据库

作者:互联网

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

复制代码
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
复制代码

标签:Files,ldf,sqlserver,MSSQLSERVER,mdf,Program,DATA
来源: https://www.cnblogs.com/gzyx1988/p/14754679.html