Sql-server – Is it possible to restore database only with .trn files

backuprestoresql server

How do I restore database only with .trn (transaction log backup) file?

I did below two steps Microsoft SQL Server Management studio shows "Restoring".

1)

RESTORE DATABASE [database_name]
  FROM DISK = N'path\file_name.bak'
  WITH MOVE N'logical_filename' TO N'path\filename.mdf',
       MOVE N'logical_filename_log to N'path\filename.ldf' REPLACE,
       NORECOVERY;
GO

2)

RESTORE LOG [database_name]
  FROM DISK = N'path\filename.trn'
  WITH NORECOVERY;
GO

Best Answer

Run this:

RESTORE LOG [database_name] FROM DISK = N'path\filename.trn' WITH RECOVERY; GO

Notice I've changed it to WITH RECOVERY - this runs the recovery process and puts the database in a usable state.

Running WITH NORECOVERY leaves the database in a state where further log files can be restored. This state prevents you using the database until you do a RESTORE LOG ... WITH RECOVERY