Introduction:
Here I will explain how to write query to take database backup in sql server or take backup of database using sql server management studio. To take database backup in sql server we need to write query like “BACKUP DATABASE DatabaseName to Disk…etc” or directly from management studio we can take backup in sql server.
Here I will explain how to write query to take database backup in sql server or take backup of database using sql server management studio. To take database backup in sql server we need to write query like “BACKUP DATABASE DatabaseName to Disk…etc” or directly from management studio we can take backup in sql server.
Description:
In
previous articles I explained 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 take database backup or take database
backup from sql
server management studio 2008.
1. With Query
With Query to take database backup:
Syntax of Query to take database
BACKUP DATABASE
DatabaseName TO DISK
='PATH TO STORE'
|
Example:
BACKUP DATABASE
MySampledb TO DISK
='E:\mysampledb.bak'
|
Once
we run above query we will get output like as shown below and it create
database backup in respective folder path
|
If
you check your folder path database backup file will exists.
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
you click on Back Up option it will open new window in that keep Backup type as
full and add destination folder path to save backup file for that click on Add button to add destination folder
path like as shown below
Now
select destination folder path and give file name like as shown below and click
OK
Once
we add our destination folder path that will be like as shown below
Now
click OK it will create database in your destination folder check it….
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. |
|||
|
|||
2 comments :
nice post sir...but sir how to take backup of database in the form of .mdf format?
the query is as following
BACKUP DATABASE DatabaseName TO DISK='E:\DatabaseName.mdf'
Note: Only a member of this blog may post a comment.