SQL Server - can I load MDF without LDF file without data loss?

I have a backup database file (i.e. test.mdf), but I don't have an LDF file. I was told that SQL Server 2008 R2 can load MDF without LDF.

It's true?

thank

+3
source share
3 answers

Assuming the database has been shut down cleanly, you can use sp_attach_single_file_db or the new CREATE DATABASE ... FOR ATTACH .

EXEC sp_attach_single_file_db 
    @dbname = 'YourDB', 
    @physname = N'C:\YourFile.mdf';

OR

CREATE DATABASE YourDB
      ON (FILENAME = 'c:\YourFile.mdf') 
      FOR ATTACH_REBUILD_LOG;
+5
source

Another option sp_attach_single_file_dbis the CREATE DATABASE command with the FOR ATTACH_REBUILD_LOG option.

0
source

. EMERGENCY :

http://forums.asp.net/t/1903548.aspx

:

  • , , , DB . . ALTER DATABASE  SET EMERGENCY, , DBCC CHECKDB REPAIR_ALLOW_DATA_LOSS. , , , , . , , , .
  • CREATE DATABASE FOR ATTACH_REBUILD_LOG, , . , . , , . DBCC CHECKDB REPAIR_ALLOW_DATA_LOSS, . , SQL Server . . , ALLOW_DATA_LOSS .

:

http://blog.sqlauthority.com/2008/07/21/sql-server-fix-error-9004-an-error-occurred-while-processing-the-log-for-database-if-possible-restore- from-backup-if-a-backup-is-not-available-it-might-be-necessary-to-rebuild-the-log /

0
source

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


All Articles