Attach an MDF file without an LDF file

Does anyone know if there is a way to include only the MDF file of the SQL Server file (without .LDF). The log file for the database is deleted, and I tried to attach the MDF, this will not work. I tried to run the script to attach the file, but did not help:

USE master;
GO
EXEC sp_attach_single_file_db @dbname = 'AdventureWorks2012', 
    @physname = 
N'C:\ProgramData\Homefront\Database\DB1.mdf';

Please, help!!!!

+4
source share
3 answers

Also try these methods ...

CREATE DATABASE AdventureWorks2012 
ON (FILENAME = N'C:\ProgramData\Homefront\Database\DB1.mdf')
FOR ATTACH_REBUILD_LOG
GO

OR Try this ...

CREATE DATABASE AdventureWorks2012 
ON  ON (FILENAME = N'C:\ProgramData\Homefront\Database\DB1.mdf')
FOR ATTACH
GO
+8
source

MDF . SQL Server 2012 C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA (, ) , .mdf .ldf db, ( , - )... AdventureWorks2012_Data.mdf. , SSMS, " " SSMS. "". "" " " ( ). , AdventureWorks2012_Data.mdf. "", . MDF LDF. LDF . LDF . "". ldf . (, ), AW2012 db .

+1

( ), ... (. ), ?

. "C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Data\log.ldf" . , /, , . , - .

-1

Source: https://habr.com/ru/post/1533810/


All Articles