SqlTutorial-1 : Lesson-12 : Class-3:
Microsoft SQL Server Training:
Free Online-Learning Classes (OLC) for T-SQL
Back-Up and Restoring Databases


1. BACKUP DATABASES

Examples

(1) Simple Back up command

BACKUP DATABASE pubs to disk ='c:\pubs.bak'

(2) Detaching database;

EXEC master.dbo.sp_dettach_db @dbname=N'copyOfdatabase', @keepfulltextindexfile='false'

(3) Backup a database with init

BACKUP DATABASE NWCopy TO NWCopyBK_1 WITH INIT GO

(4) Backup a database with DIFFERENTIAL

BACKUP DATABASE NWCopy TO NWCopyBK_1 WITH DIFFERENTIAL GO


2. RESTORE DATABASES

Examples

(1) RESTORE DATABASE WITH NON-RECOVERY

RESTORE DATABASE NWCopy
FROM  NWCopyBK_1
WITH  NORECOVERY
GO

(2) Restong DB with RECOVERY

RESTORE DATABASE NWCopy
FROM NWCopyBK_1
WITH FILE = 2, RECOVERY
GO

No comments:

Post a Comment