Transact-SQL Restore Examples

Listings 16.11 through 16.14 show some samples of restoring the database using T-SQL scripts.

Listing 16.11. Sample Script for a Full Database Recovery
--Restore northwind from the first backup on device nwbackup
-- Recover the database
USE MASTER
RESTORE DATABASE Northwind
FROM nwbackup
WITH FILE = 1,
RECOVERY
Listing 16.12. Sample Script for a Full and Log Recovery
-- Restore northwind from the first backup on device nwbackup
-- Restore two logs from device nwlogback
-- Recover the database
USE MASTER
RESTORE DATABASE northwind
FROM nwbackup
WITH FILE = 1,
NORECOVERY
GO
RESTORE LOG northwind
FROM nwlogback
WITH FILE = 1,
NORECOVERY
GO
RESTORE LOG northwind
FROM nwlogback
WITH FILE = 2,
RECOVERY
					
Listing 16.13. ...

Get Microsoft® SQL Server™ 2000 Unleashed, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.