문제

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.

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top