Wednesday, May 11, 2011

Backup Whole Database & Restore

--creating database
create database nalo
--Drop Database
drop database nalo


backup database nalo to disk='d:\office.bak'


-- veryfying backup
restore filelistonly from disk='d:\office.bak'


restore verifyonly from disk='d:\office.bak'


restore headeronly from disk='d:\office.bak'


-- creating new database from backup


restore database OfficeDB from disk='d:\office.bak' with
move 'nalo' to 'D:\officeDB\OfficeDB.mdf',
move 'nalo_log' to 'D:\officeDB\OfficeDB_log.ldf'


-- checking current selected database files

sp_helpfile


-- altering databse to modify logical names of the DB

alter database OfficeDB MODIFY FILE ( NAME = nalo, NEWNAME = OfficeDB )

Alter database OfficeDB MODIFY FILE (NAME=nalo_log,NEWNAME=OfficeDB_log)

No comments:

Post a Comment