Pages

Tuesday 23 September 2014

Restore SQL DataBase Backup On same or Different Server Using SQL Command



Most of the time i am struggling to restore to the back from interface, Different types of errors every time i need to face,  Using SQL command its more easy just have to make sure about the file names are correct and  current user have permissions to access.

You must have a Valid SQL Backup file with .bak extension, You can use this Sql command to restore the back on the same server or different Server.

Open SQL Server
Click at New Query
use the below query , just the required Parameters according to you files and locations.



Restore filelistonly from disk = 'FULL-PATH\FileName'
Go

restore database DatabaseName
from disk = 'FULL-PATH\FileName'
with
move 'Logical Name for Data File to 'FULL-PATH\FileName.mdb'

move 'Logical name for Log Fileto 'FULL-PATH\FileName.ldf'



Example
Restore filelistonly from disk = 'C:\Backups\WSS_Content_2010_Portal-Full-Database-Backup'
go
restore database WSS_Content_2013_portalTest
from disk = 'C:\Backups\ WSS_Content_2010_Portal-Full-Database-Backup'
with
move 'WSS_Content_2013_portalTest' to 'C:\Backups\WSS_Content_2013_Portal.mdf',

move 'WSS_Content_2013_portalTest_log' to 'C:\Backups\WSS_Content_2013_Portal_log.ldf'

No comments:

Post a Comment