SQL Server Performance

  • Home
  • Articles
  • Forums
  • Tips
  • Training
  • FAQ's
  • Blogs
  • Software
  • Books
  • About Us
RSS Feeds
Sign in | Join


Article Topics

All Articles
Performance Tuning
Audit
Business Intelligence
Clustering
Reporting Services
Developer
General DBA
ASP.NET / ADO.NET

Write for Us

Share your SQL Server knowledge with others and raise your profile in the community More...
Latest Articles

Working with Windows Communication Foundation (WCF)
Transfer Logins Task and Transfer Database Task in SSIS
Practical Database Change Management (Part 2)
Practical Database Change Management (Part 1)

More     
 
Latest FAQ's

ALTER TABLE SWITCH statement failed because column '%.*ls' has data type ...
ALTER TABLE SWITCH statement failed because column '%.*ls' has data type ...
ALTER TABLE SWITCH statement failed. There is no identical index in ...
'%ls' statement failed because the expression identifying partition number for the ...

More     
   
Latest Software Reviews

Spotlight on ApexSQL Diff - Server-based database comparison tool ...
Spotlight on ApexSQL Data Diff - Server-based database comparison tool ...
Spotlight on ApexSQL Doc 2008
ApexSQL Enforce

More     

articles >> general dba >> Recover Data Using Database Snapshots

Recover Data Using Database Snapshots

By : Ashish Kumar Mehta
Dec 02, 2008

The Database Snapshot feature was first introduced in SQL Server 2005 Enterprise Edition and it is also available in SQL Server 2005 Enterprise Edition. Database Administrators can create database snapshots of all the user databases irrespective of the database recovery model they are using. A database snapshot is basically a static, read-only copy of the source database at a given point in time. A Database snapshots can be used for reporting and for quick recovery of data. In this article you will see how to create and use the database snapshots feature.

How Database Snapshots Work
Database snapshots basically work at the data page level. Once you have created a database snapshot, SQL Server internally creates a sparse file. A sparse file is an empty file without any user data during the time of creation. The sparse file basically takes very less disk space during the time of creation. Whenever data get modified at the source database, the source data page prior to data modification is copied from the source database to the database snapshot (spares file). Thus the database snapshot preserves the data records like how it existed in the source database at the time when the snapshot was created. The space used by the snapshots increases as more and more data pages are modified at the source database.

Create SourceDB Database
First let us create a new database named SourceDB by executing the below mentioned TSQL code.

Use master
GO

IF  EXISTS (SELECT name FROM sys.databases WHERE name = N'SourceDB')
DROP DATABASE [SourceDB]
GO

CREATE DATABASE SourceDB
GO

Create Address Table in SourceDB Database
The next step will be to create an Address table within SourceDB database by executing the below TSQL code.

USE SourceDB
GO

IF OBJECT_ID (N'dbo.Address', N'U') IS NOT NULL
    DROP TABLE dbo.Address;
GO

/* Create Address Table*/
CREATE TABLE [dbo].[Address]
(
 [AddressID] [int] NOT NULL,
 [AddressLine1] [nvarchar](60) NOT NULL,
 [City] [nvarchar](30) NOT NULL,
 [PostalCode] [nvarchar](15) NOT NULL,
 [ModifiedDate] [datetime] NOT NULL,
 [RowGUID] [UNIQUEIDENTIFIER] NOT NULL
)
ON [PRIMARY]
GO

Populate Address Table
The next step will be to populate the Address table which you have created earlier by executing the below mentioned TSQL code. For this example we will be using the data which is available in Person.Address table of AdventureWorks database.

USE SourceDB
GO

/* Populate SourceDB.DBO.Address table with data from AdventureWorks.Person.Address */
INSERT INTO Address
SELECT
AddressID,
AddressLine1,
City,
PostalCode,
ModifiedDate,
RowGUID
FROM AdventureWorks.Person.Address
GO


    Next Page>>    








Home | Peformance Articles | Audit Articles | Business Intelligence Articles | Clustering Articles | Developer Articles | Reporting Services Articles | DBA Articles | ASP.NET / ADO.NET Articles | SQL Server Training Videos | DBA FAQ's | Developer Peformance FAQ's | DBA Peformance FAQ's | Developer FAQ's | Clustering FAQ's | Error Messages | Audit Tool Reviews | Backup Tool Reviews | Coding Tool Reviews | Compare Tool Reviews | Documentation Tool Reviews | Design Tool Reviews | Monitoring Tool Reviews | Log Tool Reviews | Reporting Tool Reviews | Clustering Tool Reviews | Security Tool Reviews | Change Management Tool Reviews | Remote Access Tool Reviews | Book Reviews | Security Tool Reviews | QDPMA Performance Tuning | ADO.NET / ASP.NET | Administration | Analysis/OLAP Services | Application Development | Configuration | Components | ETL | Hardware | High Availability | Hints | Index | Misc | Operating Systems | Performance Tuning | Replication | T-SQL | Views


              © 1999-2008 by T10 Media. All rights reserved