Introduction:
Here I will explain how to write restore database in sql server from .bak or .mdf file using query or restore database backup using sql server management studio. To restore database backup in sql server we need to write query like “RESTORE DATABASE DatabaseName FROM Disk…etc” or directly from management studio we can restore database in sql server.
Here I will explain how to write restore database in sql server from .bak or .mdf file using query or restore database backup using sql server management studio. To restore database backup in sql server we need to write query like “RESTORE DATABASE DatabaseName FROM Disk…etc” or directly from management studio we can restore database in sql server.
Description:
In
previous articles I explained take database backup in sql server, SQL injection attacks with example, SQL Server interview question and answers, joins in sql server, function example in sql server 2008, Primary key constraint in sql server, foreign key constraint in sql server, cursor example in sql server and many articles relating to SQL
server.
Now I will explain how to write query to restore database backup files (.bak or
.mdf) in sql
server
management studio 2008.
1.
with
Query
With
Query to Restore database:
Syntax
of Query to restore database
RESTORE DATABASE yourdbname
FROM DISK = 'E:\yourbackfile.bak'
WITH
MOVE 'mdffilename' TO 'E:\datayourmdffilename.mdf',
MOVE 'ldbfilename' TO 'E:\datayourldffilename.ldf'
, REPLACE
|
Example:
RESTORE DATABASE
MySampledb
FROM DISK = 'E:\mysampledb.bak'
WITH
MOVE 'MySampledb' TO 'E:\MySampledb.mdf',
MOVE 'MySampledb_log' TO 'E:\MySampledb.ldf'
, REPLACE
|
Once
we run above query we will get output like as shown below
Now
refresh your databases and check for your restored database
Directly
from SQL Server Management Studio
Open
sql
server
management studio à Select your
database à Right click on
it and select Tasks in that select Backup and click on it like as shown
below
Whenever
we click on Restore Database option it will open new window in that give
database name and select from device option in source to restore section like
as shown below
Now
click on upload icon in from device
option to give database backup file path. Whenever we click on upload icon we
will get another window to specify database like as shown below
Now
click Add option to specify database backup file (.bak or .mdf format) path and
click OK once we add our database backup file path that will be like as shown
below
Now
click OK it will added in restore database section in that select Restore
option and click OK to restore database that would be like as following screen
Once everything done we will get success message like
as shown below
If you enjoyed this post, please support the blog below. It's FREE! Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email. |
|||
|
|||
7 comments :
very helpful, sir please tell me how u create some articles demo as in gif format?
Plz share an articles about purge and shrink activity
Plz share an articles about purge and shrink activity
vry useful article
Good Article. Thanks for sharing to us
I have one abc.bak file which i have to restore in Asp.net C# internal database (microsoft sql server) .what will be procedure ??
same operation can you explain how to do via asp.net web application
Note: Only a member of this blog may post a comment.