30.06.2013 Views

SQL Server Backup and Restore - Simple Talk

SQL Server Backup and Restore - Simple Talk

SQL Server Backup and Restore - Simple Talk

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

How do we know it worked?<br />

Chapter 4: Restoring From Full <strong>Backup</strong><br />

Let's run a few quick queries, shown in Listing 4-1, against our newly restored<br />

DatabaseForFull<strong>Backup</strong>s database to verify that the data that we expect to be here is<br />

actually here.<br />

USE [DatabaseForFull<strong>Backup</strong>s]<br />

GO<br />

SELECT MessageData ,<br />

COUNT(MessageData) AS MessageCount<br />

FROM MessageTable1<br />

GROUP BY MessageData<br />

SELECT MessageData ,<br />

COUNT(MessageData) AS MessageCount<br />

FROM MessageTable2<br />

GROUP BY MessageData<br />

Listing 4-1: Checking our restored data.<br />

The first query should return a million rows, each containing the same message. The<br />

second query, if everything worked in the way we intended, should return no rows.<br />

Collecting restore metrics<br />

Having run the full backup, in Chapter 3, we were able to interrogate msdb to gather<br />

some metrics on how long the backup process took. Unfortunately, when we run a restore<br />

process using SSMS, there is no record of the length of the operation, not even in the <strong>SQL</strong><br />

<strong>Server</strong> log files.<br />

The only way to capture the time is to script out the RESTORE comm<strong>and</strong> <strong>and</strong> run the<br />

T-<strong>SQL</strong>. I won't show this script here, as we're going to run a T-<strong>SQL</strong> RESTORE comm<strong>and</strong><br />

very shortly, but if you want to see the stats for yourself, right now, you'll need to<br />

128

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!