Skip to main content

Posts

Showing posts with the label backup database

restore database with backup and transection logs

USE master GO -- First determine the number and names of the files in the backup. RESTORE FILELISTONLY FROM disk = 'C:\yourfolder\yourdbbackupfile.BAK' RESTORE DATABASE yourdatabasename FROM disk = 'C:\yourfolder\yourdbbackupfile.BAK' WITH NORECOVERY, -- change location MOVE 'xxx_Data' TO 'C:\newfolder\newfile.MDF', MOVE 'xxx_Log' TO 'C:\newfolder\newfile.LDF' GO RESTORE LOG yourdatabasename FROM disk = 'C:\yourfolder\logfile1.TRN' FROM disk = 'C:\yourfolder\logfile2.TRN' WITH NORECOVERY GO -- WITH NORECOVERY need attach database, or WITH RECOVERY then dont need attach.