AspBucket offers ASP.NET, C#, VB, Jquery, CSS, Ajax, SQL tutorials. It is the best place for programmers to learn

Sunday, 1 May 2016

Restore Database in SQL Server using SQL Query

In this article I will explain How to restore Database from .bak or.Mdf file in SQL Server using SQL Query. Please use following SQL queries for restoring the database.


RESTORE DATABASE yourdbname
FROM DISK = 'E:\yourbackfile.bak'
WITH
MOVE 'mdf_file_name' TO 'E:\data_your_mdf_filename.mdf',
MOVE 'ldb_file_name' TO 'E:\data_your_ldf_filename.ldf'
, REPLACE

Example:
RESTORE DATABASE MySampledb
FROM DISK = 'E:\sampledb.bak'
WITH
MOVE 'Sampledb' TO 'E:\Sampledb.mdf',
MOVE 'Sampledb_log' TO 'E:\Sampledb.ldf'
, REPLACE

Refresh databases and check for your restored database

0 comments :

Post a Comment

  • Popular Posts
  • Comments