Free Newsletters:
DatabaseDaily  
Database Journal
Search Database Journal:
 
MS SQL Oracle DB2 Access MySQL PostgreSQL Sybase PHP SQL Etc SQL Scripts & Samples Links Database Forum

» Database Journal Home
» Database Articles
» Database Tutorials
MS SQL
Oracle
DB2
MS Access
MySQL
» RESOURCES
Database Tools
SQL Scripts & Samples
Links
» Database Forum
» DBA Jobs
» Sitemap

News Via RSS Feed


follow us on Twitter





Brocade Doubles Down on 16 Gbps Fibre Channel

Microsoft Wants iOS Apps to Run on WP7

Avaya Debuts New Virtual Services Switch
Database Journal |DBA Support |SQLCourse |SQLCourse2







Technical Specialist – Pre-sales (MA)
Next Step Systems
US-MA-Littleton

Justtechjobs.com Post A Job | Post A Resume

Featured Database Articles

MS SQL

August 18, 2004

Restoring a SQL Database

By Muthusamy Anantha Kumar aka The MAK

When we create a backup maintenance plan with one Full backup and transaction log backups for every 15 minutes, it is sometimes necessary to restore the FULL backup and all the corresponding transactional backups sequentially. This may happen if the production box goes down or if you want to have the same database restored to another Server, etc. It is tiresome to locate all the transaction log backups and restore them one by one.

In this article, I would like to guide SQL Server DBAs to use a procedure, which can:

1.  Generate the script for restoring a full backup and all corresponding transaction log backups.

2.  Restore a full backup and all corresponding transaction log backups along with generated scripts.

3.  Restore the latest full backup and all corresponding transaction log backups as a different database.

This procedure uses xp_cmdshell and the MS-DOS 'DIR' command to find the backup and transactions log sequence based on the file date.

Let us simulate the whole backup and restore process.

Step 1

Create a database, "Inventory," in FULL recovery mode. (You can use the below script):

Use master
Go
CREATE DATABASE [inventory]  
  ON (NAME = N'inventory', 
  FILENAME = N'D:\Program Files\Microsoft SQL Server\MSSQL\data\inventory.mdf' , 
  SIZE = 1, FILEGROWTH = 10%) 
LOG ON (NAME = N'inventory_log', 
  FILENAME = N'D:\Program Files\Microsoft SQL Server\MSSQL\data\Inventory_log.LDF' , 
  FILEGROWTH = 10%)
Go
Alter DATABASE [inventory]  set recovery FULL
GO

Step 2

Create a maintenance plan with one full backup, (as shown in figure Fig 1.0), and transaction log backup for every 5 minutes, (as shown in figure Fig 2.0).


Fig 1.0


Fig 2.0

When this maintenance plan runs, it creates .BAK and .TRN files as shown in the figure Fig 3.0.


Fig 3.0

Tools:
Add databasejournal.com to your favorites
Add databasejournal.com to your browser search box
IE 7 | Firefox 2.0 | Firefox 1.5.x
Receive news via our XML/RSS feed

MS SQL Archives

Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 



Latest Forum Threads
MS SQL Forum
Topic By Replies Updated
SQL 2005: SSIS: Script Component: Working with BLOB 0010 4 January 27th, 03:03 PM
Will an MS SQL db table trigger affect the value returned by scope_identity? wreade 2 December 19th, 04:48 PM
BULK UPDATE error benedec 1 December 14th, 08:39 AM
Toggling problem in Matrix report ssrs 2008 dev_ritesh 0 December 2nd, 02:17 PM