Question

I have deleted the .ldf file. But after that I am unable to recover database. I have tried to detach and attach database but it is throwing exception.

“The database [dbName] is not accessible. (ObjectExplorer)”

I have also tried to create a new .ldf file with 0 byte size but database recovery fails. There is no backup file for database.

I have gone through a post The database [dbName] is not accessible. (ObjectExplorer) But this is related to permission where as my issue is related to deletion of .ldf file.

I do not need log file. I just want to recover my data. Transaction log is not important for me.

When I deleted .ldf file SQL server was running. I didn't stopped it at that time.Later I had restarted it.

Was it helpful?

Solution

Suppose if your database name is xyz, then run following command:

ALTER DATABASE xyz REBUILD LOG ON ( NAME = xyz_log, FILENAME ='c:\.....\xyz_log.ldf');
DBCC CHECKDB (xyz);
ALTER DATABASE xyz SET SINGLE_USER;
DBCC CHECKDB (xyz, REPAIR_ALLOW_DATA_LOSS);
ALTER DATABASE xyz SET MULTI_USER;

You may lose some data. This command doesn’t guaranteed full recovery.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top